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 <d...@axtens.net>
---
 patchwork/parser.py                       |  2 +-
 patchwork/tests/mail/0016-no-subject.mbox | 25 +++++++++++++++++++++++++
 patchwork/tests/test_parser.py            |  6 ++++++
 3 files changed, 32 insertions(+), 1 deletion(-)
 create mode 100644 patchwork/tests/mail/0016-no-subject.mbox

diff --git a/patchwork/parser.py b/patchwork/parser.py
index eab0a7d39863..1568bc446287 100644
--- a/patchwork/parser.py
+++ b/patchwork/parser.py
@@ -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
index 000000000000..6c4d7c9024f5
--- /dev/null
+++ b/patchwork/tests/mail/0016-no-subject.mbox
@@ -0,0 +1,25 @@
+From: "Yann E. MORIN" <yann.morin.1...@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.1...@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
diff --git a/patchwork/tests/test_parser.py b/patchwork/tests/test_parser.py
index 34c158441194..52de351e60bd 100644
--- a/patchwork/tests/test_parser.py
+++ b/patchwork/tests/test_parser.py
@@ -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."""
-- 
2.11.0

_______________________________________________
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork

Reply via email to