Shall upload_to return an urlencoded string or not?
|Reported by:||eibaan||Owned by:|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||yes||Patch needs improvement:||yes|
Assume a custom upload_to function. If I return any unicode string (for example "Großköln / €"), that string is tried to use as a filename and as the URL. It might be an invalid file name and/or an invalid URL. If I use django.util.http.urlquote before returning the string, it becomes a valid URL but at the same time, the file is saved as "Gro%C3%9Fk%C3%B6ln%20/%20%E2%82%AC" but is tried to load as "Großköln / €" (because the browser already decodes it) from the file system. This does not work. I think, the URL (at least the one used in the admin UI) needs to be urlencoded once more. Or the default storage should automatically make sure that it can store files under any name and is not restricted to the restrictions of the file system.
I'm not sure what's the best solution but right now, it doesn't work for anything but an unspecified safe subset of characters. And because there's one function that is the base for both the file system name and the URL path segment, I cannot easiliy fix it.
Change History (13)
Changed 7 years ago by eibaan
comment:1 Changed 7 years ago by eibaan
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:3 Changed 7 years ago by jacob
- Triage Stage changed from Unreviewed to Design decision needed
comment:8 Changed 2 years ago by aaugustin
- Easy pickings set
- Has patch set
- Needs tests set
- Patch needs improvement set
- Triage Stage changed from Design decision needed to Accepted
comment:9 Changed 2 years ago by susan
- Owner changed from nobody to susan
- Status changed from new to assigned