file.save crashes on unicode filename
|Reported by:||sylvain.lebon@…||Owned by:||fdemmer|
|Cc:||charettes, lrekucki@…||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I try to add a file into a FileField of one of my object.
The problem is I get a file with a unicode name with special characters.
name = (u'l\u2019\xe9cran.png').encode("utf-8")
now if I do
str1 = "%s%s"(MEDIA_ROOT, name)
'/home/oi/OIFS/Capture d\xe2\x80\x99\xc3\xa9cran 2012-01-24 \xc3\xa0 14.58.48.png'
and os.stat(str1) passes.
str2 = safe_join(MEDIA_ROOT, name)
str is then
u'/home/oi/OIFS/Capture d\u2019\xe9cran 2012-01-24 \xe0 14.58.48.png'
and os.stat fails.
The thing is file.save(name, content, False) uses safe_join and then os.stat.
Now I'm not sure if I should get the name in a different encoding but I don't seem to manage to get it right.
Change History (12)
comment:1 follow-ups: ↓ 4 ↓ 5 Changed 4 years ago by lrekucki
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
comment:6 Changed 4 years ago by claudep
- Component changed from File uploads/storage to Documentation
- Type changed from Uncategorized to Cleanup/optimization
comment:8 Changed 6 months ago by fdemmer
- Has patch set
- Owner changed from nobody to fdemmer
- Status changed from new to assigned
comment:9 Changed 6 months ago by charettes
- Cc charettes added; charette.s@… removed
- Version changed from 1.3 to master
comment:10 Changed 6 months ago by Tim Graham <timograham@…>
- Resolution set to fixed
- Status changed from assigned to closed