diff options
author | Andrej Shadura <andrew.shadura@collabora.co.uk> | 2021-02-04 18:33:20 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2021-02-08 11:06:15 +0100 |
commit | 434d5587280c72308744a1f3bc9bf657bc34f2e7 (patch) | |
tree | 2cb7bcb61991ad78651687c842050a8866ec2c5b /tests | |
parent | 4d154671949cd59f7e83c37bf18dad006afb6645 (diff) |
import-dsc: Delete NULs from dpkg-parsechangelog output before parsing
Commit messages may not contain NUL characters; in practice,
Debian changelogs sometimes do, usually as the result of
incorrectly used encoding for non-ASCII personal names.
As a safety net, delete all NULs from the output of dpkg-parsechangelog
before parsing it, so that they don’t get fed into Git or anything else
further in the processing.
Closes: #981340
Diffstat (limited to 'tests')
-rw-r--r-- | tests/30_test_deb_changelog.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/30_test_deb_changelog.py b/tests/30_test_deb_changelog.py index 9028621f..143f5056 100644 --- a/tests/30_test_deb_changelog.py +++ b/tests/30_test_deb_changelog.py @@ -30,6 +30,21 @@ class TestQuoting(unittest.TestCase): self.assertEquals(cl.email, 'agx@sigxcpu.org') +class TestEncoding(unittest.TestCase): + def test_nul(self): + """Test we remove NUL characters from strings when parsing (#981340)""" + changes = """git-buildpackage (0.9.2) unstable; urgency=low + + * List of ch\0nges + + -- User N\0me <agx@sigxcpu.org> Sun, 12 Nov 2017 19:00:00 +0200 +""" + cl = ChangeLog(changes) + self.assertEquals(cl.author, 'User Nme') + self.assertEquals(cl.email, 'agx@sigxcpu.org') + self.assertEquals('\0' in cl.get_changes(), False) + + @skip_without_cmd('debchange') class Test(unittest.TestCase): def setUp(self): |