Skip to content
Myr

send_file quotes ":/" in UTF-8 filename

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent 6ed68f0 · Browse files · 3 files+5 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+5 added−1 removed

  • tests:+2 added−0 removed
  • other:+3 added−1 removed

3 files+5 added−1 removed

modified:flask/helpers.py+1 added-1 removed
574 unmodified lines
575 except UnicodeEncodeError:576 filenames = {577 'filename': unicodedata.normalize(578 'NFKD', attachment_filename).encode('ascii', 'ignore'),579 'filename*': "UTF-8''%s" % url_quote(attachment_filename),579 'filename*': "UTF-8''%s" % url_quote(attachment_filename, safe=b""),580 }581 else:582 filenames = {'filename': attachment_filename}583
468 unmodified lines
modified:tests/test_helpers.py+2 added
644 unmodified lines
645 '%C3%91and%C3%BA%EF%BC%8Fping%C3%BCino.txt'),646 (u'Vögel.txt', 'Vogel.txt', 'V%C3%B6gel.txt'),647 # Native string not marked as Unicode on Python 2648 ('tést.txt', 'test.txt', 't%C3%A9st.txt'),649 # ":/" are not safe in filename* value650 (u"те:/ст", '":/"', "%D1%82%D0%B5%3A%2F%D1%81%D1%82"),651 ))652 def test_attachment_filename_encoding(self, filename, ascii, utf8):653 rv = flask.send_file('static/index.html', as_attachment=True, attachment_filename=filename)654 rv.close()
304 unmodified lines
modified:CHANGES.rst+2 added
6 unmodified lines
78- The key information for ``BadRequestKeyError`` is no longer cleared9 outside debug mode, so error handlers can still access it. This10 requires upgrading to Werkzeug 0.15.5. :issue:`3249`11- ``send_file`` url quotes the ":" and "/" characters for more12 compatible UTF-8 filename support in some browsers. :issue:`3074`131415Version 1.0.316-------------
881 unmodified lines