]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
parser: fix parsing of messages with empty subjects
authorDaniel Axtens <dja@axtens.net>
Fri, 7 Jul 2017 14:24:46 +0000 (00:24 +1000)
committerStephen Finucane <stephen@that.guru>
Wed, 12 Jul 2017 08:31:16 +0000 (09:31 +0100)
The fuzz fixups made the test too strict ("if not subject" rather than
"if subject is None") in an attempt to catch broken subject headers.
This broke parsing of messages with an empty subject.

Fix it and add a test.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
patchwork/parser.py
patchwork/tests/mail/0016-no-subject.mbox [new file with mode: 0644]
patchwork/tests/test_parser.py

index eab0a7d398639984ef6e343d57e72309653d7648..1568bc446287ed8a2e57e5e3b85fa5c5d457d67b 100644 (file)
@@ -617,7 +617,7 @@ def clean_subject(subject, drop_prefixes=None):
     prefix_re = re.compile(r'^\[([^\]]*)\]\s*(.*)$')
     subject = clean_header(subject)
 
-    if not subject:
+    if subject is None:
         raise ValueError("Invalid 'Subject' header")
 
     if drop_prefixes is None:
diff --git a/patchwork/tests/mail/0016-no-subject.mbox b/patchwork/tests/mail/0016-no-subject.mbox
new file mode 100644 (file)
index 0000000..6c4d7c9
--- /dev/null
@@ -0,0 +1,25 @@
+From: "Yann E. MORIN" <yann.morin.1998@free.fr>
+Subject:
+Date: Tue, 8 Oct 2013 22:09:47 +0000
+Message-ID: <ABC@DEF>
+
+Rename patches to follow standard naming scheme.
+
+Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
+---
+ ...d-pkgconfig-files.patch => rpi-userland-000-add-pkgconfig-files.patch} | 0
+ ...erland-001-makefiles-cmake-vmcs.cmake-allow-to-override-VMCS_IN.patch} | 0
+ 2 files changed, 0 insertions(+), 0 deletions(-)
+ rename package/rpi-userland/{rpi-userland-add-pkgconfig-files.patch => rpi-userland-000-add-pkgconfig-files.patch} (100%)
+ rename package/rpi-userland/{rpi-userland-makefiles-0001-cmake-vmcs.cmake-allow-to-override-VMCS_IN.patch => rpi-userland-001-makefiles-cmake-vmcs.cmake-allow-to-override-VMCS_IN.patch} (100%)
+
+diff --git a/package/rpi-userland/rpi-userland-add-pkgconfig-files.patch b/package/rpi-userland/rpi-userland-000-add-pkgconfig-files.patch
+similarity index 100%
+rename from package/rpi-userland/rpi-userland-add-pkgconfig-files.patch
+rename to package/rpi-userland/rpi-userland-000-add-pkgconfig-files.patch
+diff --git a/package/rpi-userland/rpi-userland-makefiles-0001-cmake-vmcs.cmake-allow-to-override-VMCS_IN.patch b/package/rpi-userland/rpi-userland-001-makefiles-cmake-vmcs.cmake-allow-to-override-VMCS_IN.patch
+similarity index 100%
+rename from package/rpi-userland/rpi-userland-makefiles-0001-cmake-vmcs.cmake-allow-to-override-VMCS_IN.patch
+rename to package/rpi-userland/rpi-userland-001-makefiles-cmake-vmcs.cmake-allow-to-override-VMCS_IN.patch
+-- 
+1.8.1.2
index 34c158441194f35784e5d65699db1f272e2995b3..52de351e60bd83059cc77a1430fbe82461cd857f 100644 (file)
@@ -609,6 +609,12 @@ class PatchParseTest(PatchTest):
         # Confirm we got both markers
         self.assertEqual(2, diff.count('\ No newline at end of file'))
 
+    def test_no_subject(self):
+        """Validate parsing a mail with no subject."""
+        diff, message = self._find_content('0016-no-subject.mbox')
+        self.assertTrue(diff is not None)
+        self.assertTrue(message is not None)
+
 
 class EncodingParseTest(TestCase):
     """Test parsing of patches with different encoding issues."""