I'm submitting a ...
Do you want to request a feature or report a bug?
Report a bug.
What is the current behavior?
cherrypy.lib.static.serve_file() method sets wrong "Content-Disposition" and doesn't encode UTF-8 filename properly. It causes error with browser suggested filename - when downloading the file, the value is "download" and it doesn't matter what the original filename is. This could be fixed with RFC6266 (https://tools.ietf.org/html/rfc6266#appendix-D) solution, e.g. filename="my-resume.pdf"; filename*=utf-8''My%20R%C3%A9sum%C3%A9.pdf.
If the current behavior is a bug, please provide the steps to reproduce and if possible a screenshots and logs of the problem. If you can, show us your code.
Code:
return cherrypy.lib.static.serve_file(
path='file_path',
content_type='file_mime_type',
disposition='attachment',
name='has_utf-8_character_☃.html',
debug=True)
DEBUG:
TOOLS.STATIC Content-Disposition: 'attachment; filename="has_utf-8_character_☃.html"'
What is the expected behavior?
DEBUG:
TOOLS.STATIC Content-Disposition: 'attachment; filename="has_utf-8_character_.html"; filename*=utf-8''has_utf-8_character_%E2%98%83.html'
What is the motivation / use case for changing the behavior?
To be able return file with czech diacritics in name for download under its original name.
Please tell us about your environment:
- Cheroot version: v6.5.4
- CherryPy version: v18.0.1
- Python version: v3.6.6
- OS: Windows 10
- Browser: [all]
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, e.g. stackoverflow, gitter, etc.)
https://stackoverflow.com/questions/1361604/how-to-encode-utf8-filename-for-http-headers-python-django/8996249#8996249
I'm submitting a ...
Do you want to request a feature or report a bug?
Report a bug.
What is the current behavior?
cherrypy.lib.static.serve_file() method sets wrong "Content-Disposition" and doesn't encode UTF-8 filename properly. It causes error with browser suggested filename - when downloading the file, the value is "download" and it doesn't matter what the original filename is. This could be fixed with RFC6266 (https://tools.ietf.org/html/rfc6266#appendix-D) solution, e.g. filename="my-resume.pdf"; filename*=utf-8''My%20R%C3%A9sum%C3%A9.pdf.
If the current behavior is a bug, please provide the steps to reproduce and if possible a screenshots and logs of the problem. If you can, show us your code.
Code:
DEBUG:
TOOLS.STATIC Content-Disposition: 'attachment; filename="has_utf-8_character_☃.html"'
What is the expected behavior?
DEBUG:
TOOLS.STATIC Content-Disposition: 'attachment; filename="has_utf-8_character_.html"; filename*=utf-8''has_utf-8_character_%E2%98%83.html'
What is the motivation / use case for changing the behavior?
To be able return file with czech diacritics in name for download under its original name.
Please tell us about your environment:
Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, e.g. stackoverflow, gitter, etc.)
https://stackoverflow.com/questions/1361604/how-to-encode-utf8-filename-for-http-headers-python-django/8996249#8996249