]> git.ozlabs.org Git - patchwork/commitdiff
parser: allow words starting with "diff" at beginning of line
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Sat, 14 Jan 2012 01:17:40 +0000 (01:17 +0000)
committerJeremy Kerr <jk@ozlabs.org>
Sat, 14 Jan 2012 19:29:26 +0000 (19:29 +0000)
The patch parser splits emails incorrectly when the comment contains a
line whose first word starts with "diff" (like "difficult" or
"different").

For a real-life example of an email that triggers this bug, see
http://patchwork.ozlabs.org/patch/135291/.

Fix the issue by checking for a space after "diff".  Add
DiffWordInCommentTest to the test suite.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
apps/patchwork/parser.py
apps/patchwork/tests/patchparser.py

index 2b5e9a093c478756d65ef001cdb59e48eb0af0c5..f4605668e67a78f9f7cbd1a5e4018251ba2caf17 100644 (file)
@@ -68,7 +68,7 @@ def parse_patch(text):
         line += '\n'
 
         if state == 0:
-            if line.startswith('diff') or line.startswith('===') \
+            if line.startswith('diff ') or line.startswith('===') \
                     or line.startswith('Index: '):
                 state = 1
                 buf += line
index 3870dc88bb2f29728b5f684913b4473ad0e27024..06b4e546e129fbfb3b96609c769dbeacc6091015 100644 (file)
@@ -121,6 +121,11 @@ class ListFooterTest(InlinePatchTest):
         (self.patch, self.comment) = find_content(self.project, email)
 
 
+class DiffWordInCommentTest(InlinePatchTest):
+    test_comment = 'Lines can start with words beginning in "diff"\n' + \
+                   'difficult\nDifferent'
+
+
 class UpdateCommentTest(InlinePatchTest):
     """ Test for '---\nUpdate: v2' style comments to patches. """
     patch_filename = '0001-add-line.patch'