FileSystemStorage generates wrong URL when path contains special characters
|Reported by:||e.generalov||Owned by:||nobody|
|Cc:||paulegan@…||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I have a model with models.FileField and admin interface. When I upload any file that contains special characters in the name (for example
test#12.jpg), then I can't to download it by link in the admin change form.
There is a bug in the FileSystemStorage URL generation algorithm. This doesn't escapes special characters. Therefore the '/media/test#12.jpg' URL is produced and browser treats #12.jpg as a fragment part.
I notice same bug in the https://github.com/sorl/sorl-thumbnail/blob/legacy/sorl/thumbnail/main.py#L96 too, where iri_to_uri() is used for filepath-to-uri convertion (this method gives a wrong result too).
Therefore I suggest to place such function in the django core (see the patch).
Change History (8)
comment:1 Changed 6 years ago by
|Patch needs improvement:||unset|
|Triage Stage:||Unreviewed → Ready for checkin|