Skip to content
Myr

Merge pull request #2238 from davidism/bugfix/latin1-filename

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

filename can be latin-1, not just ascii

authored by David Lord · committed by GitHub · parents e13eaee, 09b4910 · Browse files · 1 file+4 added−7 removed
This commit

State

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

Diff stats

1 file+4 added−7 removed

  • other:+4 added−7 removed

1 file+4 added−7 removed

modified:flask/helpers.py+4 added-7 removed
482 unmodified lines
483 UTF-8 filenames, as specified in `RFC 2231`_, are supported.484 485 .. _RFC 2231: https://tools.ietf.org/html/rfc2231#section-4486487 :param filename_or_fp: the filename of the file to send in `latin-1`.487 :param filename_or_fp: the filename of the file to send.488 This is relative to the :attr:`~Flask.root_path`489 if a relative path is specified.490 Alternatively a file object might be provided in491 which case ``X-Sendfile`` might not work and fall
48 unmodified lines
540 if attachment_filename is None:541 raise TypeError('filename unavailable, required for '542 'sending as attachment')543544 normalized = unicodedata.normalize(545 'NFKD', text_type(attachment_filename)546 )547544 try:549 normalized.encode('ascii')545 attachment_filename = attachment_filename.encode('latin-1')546 except UnicodeEncodeError:547 filenames = {552 'filename': normalized.encode('ascii', 'ignore'),548 'filename': unicodedata.normalize(549 'NFKD', attachment_filename).encode('latin-1', 'ignore'),550 'filename*': "UTF-8''%s" % url_quote(attachment_filename),551 }552 else:553 filenames = {'filename': attachment_filename}
424 unmodified lines