summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2017-11-12 18:38:41 +0100
committerGuido Günther <agx@sigxcpu.org>2017-11-12 18:41:20 +0100
commit3b5a7ddbe6f230bcb659104765a2da0837a3f283 (patch)
treecdd368fab90ab545c75a7aa4cdcb92291dcb60d5
parent758908b3b08cd94d412b3d146d7be9bb1256dc25 (diff)
changelog: handle comma in maintainers name
Thanks: Andreas Beckmann for the proposed fix Closes: #737623
-rw-r--r--gbp/deb/changelog.py21
-rw-r--r--tests/30_test_deb_changelog.py26
2 files changed, 45 insertions, 2 deletions
diff --git a/gbp/deb/changelog.py b/gbp/deb/changelog.py
index bcda3f4c..1d499821 100644
--- a/gbp/deb/changelog.py
+++ b/gbp/deb/changelog.py
@@ -190,14 +190,15 @@ class ChangeLog(object):
"""
The author of the last modification
"""
- return email.utils.parseaddr(self._cp['Maintainer'])[0]
+
+ return self._parse_maint(self._cp['Maintainer'])[0]
@property
def email(self):
"""
The author's email
"""
- return email.utils.parseaddr(self._cp['Maintainer'])[1]
+ return self._parse_maint(self._cp['Maintainer'])[1]
@property
def date(self):
@@ -326,3 +327,19 @@ class ChangeLog(object):
def get_changes(self, since='0~'):
return self._run_parsechangelog(['-v%s' % since, '-SChanges'])
+
+ @staticmethod
+ def _parse_maint(maintainer):
+ """
+ Parse maintainer
+
+ Mostly rfc822 but we allow for commas
+ """
+ def _quote(u):
+ return u.replace(',', '##comma##')
+
+ def _unquote(q):
+ return q.replace('##comma##', ',')
+
+ name, mail = email.utils.parseaddr(_quote(maintainer or ''))
+ return (_unquote(name), _unquote(mail))
diff --git a/tests/30_test_deb_changelog.py b/tests/30_test_deb_changelog.py
new file mode 100644
index 00000000..8587a675
--- /dev/null
+++ b/tests/30_test_deb_changelog.py
@@ -0,0 +1,26 @@
+# vim: set fileencoding=utf-8 :
+
+"""
+Test L{gbp.deb.changelog.Changelog}
+
+Test things here that don't fit nicely into the doctests that
+also make up the API documentation.
+"""
+
+import unittest
+
+from gbp.deb.changelog import ChangeLog
+
+
+class TestQuoting(unittest.TestCase):
+ def test_comma(self):
+ """Test we properly parse maitainers with comma #737623"""
+ changes = """git-buildpackage (0.9.2) unstable; urgency=low
+
+ * List of changes
+
+ -- Guido Günther, aftercomma <agx@sigxcpu.org> Sun, 12 Nov 2017 19:00:00 +0200
+"""
+ cl = ChangeLog(changes)
+ self.assertEquals(cl.author, 'Guido Günther, aftercomma')
+ self.assertEquals(cl.email, 'agx@sigxcpu.org')