Skip to content
Snippets Groups Projects
Commit e5815560 authored by John Wright's avatar John Wright
Browse files

Allow ':' as the first character of a value

The regular expression that matched keys was too loose, so things like

  Foo: : bar

would get parsed as

  {'Foo:': 'bar'}

instead of the correct value (which is also returned by both apt_pkg and
the email package),

  {'Foo': ': bar'}

Closes: #597249

(cherry picked from commit 86ddf35b)
parent 28a6c5f6
No related branches found
No related tags found
No related merge requests found
python-debian (0.1.18+squeeze1) stable; urgency=low
* Allow ':' as the first character of a value. This fixes an
implementation error where the paragraph
Foo: : bar
would be interpreted as
{'Foo:': 'bar'}
by the Python-native parser, while it would be correctly interpreted
as
{'Foo': ': bar'}
by both the apt_pkg parser and the Python email library.
(Closes: #597249)
-- John Wright <jsw@debian.org> Wed, 28 Dec 2011 14:50:57 -0800
python-debian (0.1.18) unstable; urgency=low
* Support installation together with older versions of python-apt.
......
......@@ -317,9 +317,11 @@ class Deb822(Deb822Dict):
###
def _internal_parser(self, sequence, fields=None):
single = re.compile("^(?P<key>\S+)\s*:\s*(?P<data>\S.*?)\s*$")
multi = re.compile("^(?P<key>\S+)\s*:\s*$")
multidata = re.compile("^\s(?P<data>.+?)\s*$")
# The key is non-whitespace, non-colon characters before any colon.
key_part = r"^(?P<key>[^: \t\n\r\f\v]+)\s*:\s*"
single = re.compile(key_part + r"(?P<data>\S.*?)\s*$")
multi = re.compile(key_part + r"$")
multidata = re.compile(r"^\s(?P<data>.+?)\s*$")
wanted_field = lambda f: fields is None or f in fields
......
......@@ -726,6 +726,15 @@ Description: python modules to work with Debian-related data formats
self.assertEqual(p2['uploaders'],
u'Frank Küster <frank@debian.org>')
def test_bug597249_colon_as_first_value_character(self):
"""Colon should be allowed as the first value character. See #597249.
"""
data = 'Foo: : bar'
parsed = {'Foo': ': bar'}
self.assertWellParsed(deb822.Deb822(data), parsed)
class TestPkgRelations(unittest.TestCase):
def test_packages(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment