Merge "swob.Match: Optional whitespace is optional"

This commit is contained in:
Zuul
2018年04月10日 08:13:39 +00:00
committed by Gerrit Code Review

View File

@@ -622,7 +622,10 @@ class Match(object):
"""
def __init__(self, headerval):
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('"'):
self.tags.add(tag[1:-1])
else:

View File

@@ -285,6 +285,20 @@ class TestMatch(unittest.TestCase):
self.assertIn('b', 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):
def test_is_chunked(self):
Reference in New Issue
openstack/swift
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.

The note is not visible to the blocked user.