]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
parser: Ensure whitespace is stripped for long headers
authorStephen Finucane <stephen@that.guru>
Sun, 4 Nov 2018 14:06:03 +0000 (14:06 +0000)
committerStephen Finucane <stephen@that.guru>
Sat, 22 Dec 2018 18:04:21 +0000 (18:04 +0000)
RFC2822 states that long headers can be wrapped using CRLF followed by
WSP [1]. For example:

    Subject: Foo bar,
     baz

Should be parsed as:

    Foo bar,baz

While we were stripping the former, we were not stripping the
latter. This mean that we ended up with the following:

    Foo bar, baz

Resolve this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #197
patchwork/parser.py
patchwork/tests/test_parser.py
releasenotes/notes/issue-197-4f7594db1e4c9887.yaml [new file with mode: 0644]

index d6fa84372121b3c913f6a8ee9481445ab7207532..946b66851d7c12808d184e05dbb5be9dd69a53e9 100644 (file)
@@ -47,6 +47,7 @@ class DuplicateMailError(Exception):
 
 
 def normalise_space(value):
+    value = ''.join(re.split(r'\n\s+', value))
     whitespace_re = re.compile(r'\s+')
     return whitespace_re.sub(' ', value).strip()
 
index a9df5e351d7efe77aff1d5d13f76bc8926384316..664edd5bab445d35566f142e7866796980a7a479 100644 (file)
@@ -832,6 +832,8 @@ class SubjectTest(TestCase):
         self.assertEqual(clean_subject('[PATCH] meep'), ('meep', []))
         self.assertEqual(clean_subject("[PATCH] meep \n meep"),
                          ('meep meep', []))
+        self.assertEqual(clean_subject("[PATCH] meep,\n meep"),
+                         ('meep,meep', []))
         self.assertEqual(clean_subject('[PATCH RFC] meep'),
                          ('[RFC] meep', ['RFC']))
         self.assertEqual(clean_subject('[PATCH,RFC] meep'),
diff --git a/releasenotes/notes/issue-197-4f7594db1e4c9887.yaml b/releasenotes/notes/issue-197-4f7594db1e4c9887.yaml
new file mode 100644 (file)
index 0000000..2777fbc
--- /dev/null
@@ -0,0 +1,7 @@
+---
+fixes:
+  - |
+    Long headers can be wrapped using CRLF followed by WSP (whitespace). This
+    whitespace was not being stripped, resulting in errant whitespace being
+    saved for the patch subject. This is resolved though existing patches and
+    cover letters will need to be updated manually.