send_file fails when filename contains unicode symbols
See original GitHub issueHi.
I’ve detected an issue with supporting unicode filenames in send_file.
If send_file attempts to respond with utf-8 in http headers, the answer is empty, the log contains something like “http-headers should containbe latin-1”.
I know that browser support IS A MESS, but it seems, that sending two filenames (filename=
and filename*=
) separated by semicolon should work.
I’d like this to be handled by flask or werkzeug. Will you accept such pull request?
Issue Analytics
- State:
- Created 9 years ago
- Reactions:2
- Comments:38 (22 by maintainers)
Top Results From Across the Web
Send files with Unicode characters in filename using requests ...
So python has to convert the string to a unicode object first. ... But the decode fails because the string isn't valid ascii....
Read more >Erlang -- file
RawFilename is a filename not subject to Unicode translation, meaning that it can contain characters not conforming to the Unicode encoding expected from...
Read more >File upload and download troubleshooting FAQs - Pega Support
You cannot upload files with names containing Unicode characters (multibyte) because of character set mismatch at the Operator System level ...
Read more >Changes — Flask Documentation (2.2.x)
Old names for some send_file parameters have been removed. download_name replaces ... Using built-in RequestContext, unprintable Unicode characters in Host ...
Read more >File names not recognised if cpinternal is UTF-8 and filename ...
Most ABL file operations fail on Windows if the filename or path contains extended characters and the client is running with -cpinternal ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Similar discussion has already happened regarding this observation. See the issue from
requests
to read more about the details, but the short of it is that HTTP headers are supposed to only acceptlatin-1
characters. Changing this behavior in flask or werkzeug would only cause issues and break running code by allowing requests to be sent in an unsupported encoding to webservers which expect to getlatin-1
.Someone else can chime in if I am mistaken, but I think this can be closed.
Similar discussion: https://github.com/kennethreitz/requests/issues/1926 https://github.com/jakubroztocil/httpie/issues/212
BTW, I’ve solved the problem by sending filename*=utf-8’blah’ header field. Works everywhere except for the IE <= 8.
Here is the snippet:
Looks like a more correct way of fixing this.