diff options
author | Michael Ellerman <mpe@ellerman.id.au> | 2015-03-18 14:39:24 +1100 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2015-03-22 21:27:09 +0800 |
commit | 86f645abb13ff65ef04b085b443168d5b5622e4d (patch) | |
tree | 912de7d2ea948d9057a6023c53884dafcd774938 /apps/patchwork/parser.py | |
parent | 93aa30e45f7502f3209bf5ebf4e7966ff5a26899 (diff) | |
download | patchwork-86f645abb13ff65ef04b085b443168d5b5622e4d.tar.bz2 patchwork-86f645abb13ff65ef04b085b443168d5b5622e4d.tar.xz |
parser: Fix parsing of patches with a trailing no-newline marker
If a patch ends with a "No newline at end of file" marker, it is
incorrectly considered part of the comment.
Add a testcase which shows the bug, and then fix the parser. The parser
fix is hopefully sufficiently specific so as to not break any other
unrelated case. But ..
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'apps/patchwork/parser.py')
-rw-r--r-- | apps/patchwork/parser.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/apps/patchwork/parser.py b/apps/patchwork/parser.py index 76f409c..a51a7b6 100644 --- a/apps/patchwork/parser.py +++ b/apps/patchwork/parser.py @@ -126,6 +126,11 @@ def parse_patch(text): buf = '' state = 2 + elif hunk and line.startswith('\ No newline at end of file'): + # If we had a hunk and now we see this, it's part of the patch, + # and we're still expecting another @@ line. + patchbuf += line + elif hunk: state = 1 buf += line |