Skip to content

Commit

Permalink
Merge pull request #641 from kxepal/issue/520
Browse files Browse the repository at this point in the history
(#520) Always quote params for Content-Disposition
  • Loading branch information
asvetlov committed Nov 23, 2015
2 parents 8d0cfc1 + 19305a9 commit 05bf227
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
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

0 comments on commit 05bf227

Please sign in to comment.