]> git.ipfire.org Git - thirdparty/patchwork.git/commit
parser: Don't extract diffs from replies
authorStephen Finucane <stephen@that.guru>
Sun, 9 Apr 2017 15:08:40 +0000 (16:08 +0100)
committerStephen Finucane <stephen@that.guru>
Sat, 15 Apr 2017 11:23:41 +0000 (12:23 +0100)
commit69e7e366593eeb19cf9ec65ba1ca9649e9c7ccb0
tree7968338ded1a698347f9999c7c1596d2f4bb67e4
parent919962620a9986f1fde7cba1b4a13998ccc2b7b7
parser: Don't extract diffs from replies

In '2a915efd', a check was added to ensure mails prefixed with 'RE:' or
similar would not be parsed as patches. By time this check actually
happens, any patches had already been extracted from the mail thus these
patches were re-added to the mail content before saving the comment.
Unfortunately, this didn't take into account cases where a patch or diff
was not the last part of a mail but rather located somewhere in the
middle of the content:

    Introduction content
    Diff or patch content ***
    Additional content

This would result in mangling of the mail as the patch would _always_ be
appended to the end:

    Introduction content
    Additional content
    Diff or patch content ***

Handle this by only breaking a mail into a comment and a diff if there
is any possibility that we might want to use that diff.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 2a915efd ("parser: fix wrong parsing of diff comments")
Closes-bug: #95
patchwork/parser.py
patchwork/tests/test_parser.py