]> 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 22:35:48 +0000 (22:35 +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
(cherry picked from commit 841f966b8d54b2f51ab1c498eed6e5391f2546a9)

patchwork/parser.py
patchwork/tests/test_parser.py
releasenotes/notes/issue-197-4f7594db1e4c9887.yaml [new file with mode: 0644]

index 40a80f267e6525160c0234ae27c7149bd5e0a68b..0d335b71b806f04e19ba64ead7baa0c9e3a4e142 100644 (file)
@@ -56,6 +56,7 @@ logger = logging.getLogger(__name__)
 
 
 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 e99cf214e01d8cabd3e68adb57a4b196b186a890..b9336d377f279e4898f61367f206f897676f51fb 100644 (file)
@@ -846,6 +846,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.