fixup!Patch of "parse_content_disposition" method to meet RFC2183

The spec of Content-Disposition does not require a space character after
comma: http://www.ietf.org/rfc/rfc2183.txt

Change-Id: Iff438dc36ce78c6a79bb66ab3d889a8dae7c0e1f
Closes-Bug: #1458497
This commit is contained in:
Michael MATUR 2015-05-25 15:13:01 +02:00
parent e9a032f896
commit e7c8c578d9
2 changed files with 8 additions and 2 deletions

View File

@ -3355,8 +3355,8 @@ def parse_content_disposition(header):
"""
attributes = {}
attrs = ''
if '; ' in header:
header, attrs = header.split('; ', 1)
if ';' in header:
header, attrs = [x.strip() for x in header.split(';', 1)]
m = True
while m:
m = ATTRIBUTES_RE.match(attrs)

View File

@ -4629,6 +4629,12 @@ class TestParseContentDisposition(unittest.TestCase):
self.assertEquals(name, 'form-data')
self.assertEquals(attrs, {'name': 'somefile', 'filename': 'test.html'})
def test_content_disposition_without_white_space(self):
name, attrs = utils.parse_content_disposition(
'form-data;name="somefile";filename="test.html"')
self.assertEquals(name, 'form-data')
self.assertEquals(attrs, {'name': 'somefile', 'filename': 'test.html'})
class TestIterMultipartMimeDocuments(unittest.TestCase):