Merge "swob.Match: Optional whitespace is optional"
This commit is contained in:
commit
bbf5e5c7f3
@ -622,7 +622,10 @@ class Match(object):
|
|||||||
"""
|
"""
|
||||||
def __init__(self, headerval):
|
def __init__(self, headerval):
|
||||||
self.tags = set()
|
self.tags = set()
|
||||||
for tag in headerval.split(', '):
|
for tag in headerval.split(','):
|
||||||
|
tag = tag.strip()
|
||||||
|
if not tag:
|
||||||
|
continue
|
||||||
if tag.startswith('"') and tag.endswith('"'):
|
if tag.startswith('"') and tag.endswith('"'):
|
||||||
self.tags.add(tag[1:-1])
|
self.tags.add(tag[1:-1])
|
||||||
else:
|
else:
|
||||||
|
@ -285,6 +285,20 @@ class TestMatch(unittest.TestCase):
|
|||||||
self.assertIn('b', match)
|
self.assertIn('b', match)
|
||||||
self.assertNotIn('c', match)
|
self.assertNotIn('c', match)
|
||||||
|
|
||||||
|
def test_match_no_optional_white_space(self):
|
||||||
|
match = swift.common.swob.Match('"a","b"')
|
||||||
|
self.assertEqual(match.tags, set(('a', 'b')))
|
||||||
|
self.assertIn('a', match)
|
||||||
|
self.assertIn('b', match)
|
||||||
|
self.assertNotIn('c', match)
|
||||||
|
|
||||||
|
def test_match_lots_of_optional_white_space(self):
|
||||||
|
match = swift.common.swob.Match('"a" , , "b" ')
|
||||||
|
self.assertEqual(match.tags, set(('a', 'b')))
|
||||||
|
self.assertIn('a', match)
|
||||||
|
self.assertIn('b', match)
|
||||||
|
self.assertNotIn('c', match)
|
||||||
|
|
||||||
|
|
||||||
class TestTransferEncoding(unittest.TestCase):
|
class TestTransferEncoding(unittest.TestCase):
|
||||||
def test_is_chunked(self):
|
def test_is_chunked(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user