Hello release managers, Attached is a patch to the python-debian package which I intend to upload to stable. It fixes #597249 [1], which causes problems for some well-formed data. Specifically, it is problematic when parsing Vcs-Cvs headers, like
Vcs-Cvs: :ext:_anon...@anoncvs.mirbsd.org:/cvs contrib/hosted/tg/deb/cvs (See #637524 [2].) Iain requested a backport of a version that had that fix included, but several people suggested that the fix should go through the normal stable update channels instead of using backports to fix bugs. The patch is a non-conflicting (except for the changelog) cherry-pick of the commit to the master branch that fixed the bug and added the regression test [3]. [1]: http://bugs.debian.org/597249#20 [2]: http://bugs.debian.org/637524#35 [3]: http://git.debian.org/?p=pkg-python-debian/python-debian.git;a=commitdiff;h=86ddf35be8995a0262e2753a515ebc623fcbe16f -- John Wright <j...@debian.org>
From e581556051c8cf96fc9ac4bb09bd91e03e825471 Mon Sep 17 00:00:00 2001 From: John Wright <j...@debian.org> Date: Sun, 3 Jul 2011 02:36:39 -0700 Subject: [PATCH] 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 86ddf35be8995a0262e2753a515ebc623fcbe16f) --- debian/changelog | 21 +++++++++++++++++++++ lib/debian/deb822.py | 8 +++++--- tests/test_deb822.py | 9 +++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 0292524..170a6ca 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,24 @@ +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 <j...@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. diff --git a/lib/debian/deb822.py b/lib/debian/deb822.py index a0cad69..84a4a74 100644 --- a/lib/debian/deb822.py +++ b/lib/debian/deb822.py @@ -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 diff --git a/tests/test_deb822.py b/tests/test_deb822.py index 891f4cd..e29a12d 100755 --- a/tests/test_deb822.py +++ b/tests/test_deb822.py @@ -726,6 +726,15 @@ Description: python modules to work with Debian-related data formats self.assertEqual(p2['uploaders'], u'Frank Küster <fr...@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): -- 1.7.5.4
signature.asc
Description: Digital signature