bradleyg / django-s3direct

Directly upload files to S3 compatible services with Django.
MIT License
653 stars 234 forks source link

`get_key` and related key functions provided in the examples don't sanitise non-urlsafe characters in file names #185

Open rollcat opened 5 years ago

rollcat commented 5 years ago

When used with Django's default URLField, file names with emoji, etc are successfully uploaded, but don't pass validation when the URL is submitted to the form handler.

I've worked around this by doing this with the user-supplied filename in my code:

filename = urllib.parse.quote(filename.encode("ascii", "ignore").decode().strip())

I'm not sure if the above method is not overkill, but URLField no longer complains.