Merge "fixup!Patch of "parse_content_disposition" method to meet RFC2183"

This commit is contained in:
Jenkins 2015-05-27 13:15:16 +00:00 committed by Gerrit Code Review
commit ccb07cfd4d
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):