Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#520) Always quote params for Content-Disposition #641

Merged
merged 1 commit into from
Nov 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions aiohttp/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,11 +756,9 @@ def set_content_disposition(self, disptype, **params):
raise ValueError('bad content disposition parameter'
' {!r}={!r}'.format(key, val))
qval = quote(val, '')
lparams.append((key, '"%s"' % qval))
if key == 'filename':
lparams.append((key, '"%s"' % qval))
lparams.append(('filename*', "utf-8''" + qval))
else:
lparams.append((key, "%s" % qval))
sparams = '; '.join('='.join(pair) for pair in lparams)
value = '; '.join((value, sparams))
self.headers[CONTENT_DISPOSITION] = value
Expand Down
2 changes: 1 addition & 1 deletion tests/test_multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def test_autoset_content_disposition(self):
def test_set_content_disposition(self):
self.part.set_content_disposition('attachment', foo='bar')
self.assertEqual(
'attachment; foo=bar',
'attachment; foo="bar"',
self.part.headers[CONTENT_DISPOSITION])

def test_set_content_disposition_bad_type(self):
Expand Down