Merge pull request #2223 from antlarr/master
Fix send_file's attachment_filename to work with non-ascii filenames
This commit is contained in:
commit
8b45009dbc
2 changed files with 37 additions and 3 deletions
|
|
@ -540,10 +540,11 @@ class TestSendfile(object):
|
|||
value, options = \
|
||||
parse_options_header(rv.headers['Content-Disposition'])
|
||||
assert value == 'attachment'
|
||||
assert options['filename'] == 'index.html'
|
||||
assert 'filename*' not in rv.headers['Content-Disposition']
|
||||
rv.close()
|
||||
|
||||
with app.test_request_context():
|
||||
assert options['filename'] == 'index.html'
|
||||
rv = flask.send_file('static/index.html', as_attachment=True)
|
||||
value, options = parse_options_header(rv.headers['Content-Disposition'])
|
||||
assert value == 'attachment'
|
||||
|
|
@ -560,6 +561,19 @@ class TestSendfile(object):
|
|||
assert options['filename'] == 'index.txt'
|
||||
rv.close()
|
||||
|
||||
def test_attachment_with_utf8_filename(self):
|
||||
app = flask.Flask(__name__)
|
||||
|
||||
with app.test_request_context():
|
||||
rv = flask.send_file('static/index.html', as_attachment=True, attachment_filename=u'Ñandú/pingüino.txt')
|
||||
content_disposition = set(rv.headers['Content-Disposition'].split('; '))
|
||||
assert content_disposition == set((
|
||||
'attachment',
|
||||
'filename="Nandu/pinguino.txt"',
|
||||
"filename*=UTF-8''%C3%91and%C3%BA%EF%BC%8Fping%C3%BCino.txt"
|
||||
))
|
||||
rv.close()
|
||||
|
||||
def test_static_file(self):
|
||||
app = flask.Flask(__name__)
|
||||
# default cache timeout is 12 hours
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue