Fix previous commits to work with python 2 and python 3

Also, parse_options_header seems to interpret filename* so we better
test the actual value used in the headers (and since it's valid
in any order, use a set to compare)
This commit is contained in:
Antonio Larrosa 2017-03-24 20:05:01 +01:00
parent 0049922f2e
commit 6ef45f30ab
2 changed files with 6 additions and 5 deletions

View file

@ -536,7 +536,7 @@ def send_file(filename_or_fp, mimetype=None, as_attachment=False,
raise TypeError('filename unavailable, required for '
'sending as attachment')
filename_dict = {
'filename': unidecode(attachment_filename),
'filename': unidecode(text_type(attachment_filename)),
'filename*': "UTF-8''%s" % url_quote(attachment_filename)}
headers.add('Content-Disposition', 'attachment',
**filename_dict)