forked from orbit-oss/flask
Make sure the attachment filename is text type.
If attachment filename is bytes type and contains non-ascii coded bytes, then the following ASCII encoding process will trigger UnicodeDecodeError exception. Fix issue #2933.
This commit is contained in:
parent
232e5c81bc
commit
40118e785f
3 changed files with 10 additions and 1 deletions
|
|
@ -567,6 +567,9 @@ def send_file(filename_or_fp, mimetype=None, as_attachment=False,
|
|||
raise TypeError('filename unavailable, required for '
|
||||
'sending as attachment')
|
||||
|
||||
if not isinstance(attachment_filename, text_type):
|
||||
attachment_filename = attachment_filename.decode('utf-8')
|
||||
|
||||
try:
|
||||
attachment_filename = attachment_filename.encode('ascii')
|
||||
except UnicodeEncodeError:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue