diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-03-19 21:48:32 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-03-19 21:48:32 -0400 |
commit | 367be74dfd02735cc989258d1a58ce05a8ebc886 (patch) | |
tree | 3fb49c4920f07f03f0e418fe3d70a0418e6f486f | |
parent | 1686b0fbebdbb4557bebb3d1ee316d928d050bc5 (diff) | |
download | b4-367be74dfd02735cc989258d1a58ce05a8ebc886.tar.gz |
Properly handle blank lines in patches
We don't need to strip() patches, because a) it introduces a problem if
the patch has blank lines in it, and b) because it doesn't matter if
there's anything trailing at the end.
We still need better handling for obviously broken patches, but at least
valid ones shouldn't cause problems.
Reported-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r-- | b4/__init__.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/b4/__init__.py b/b4/__init__.py index d6ca6de..ae7e452 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -670,7 +670,6 @@ class LoreMessage: # XXX: This currently doesn't work for git binary patches # diff = diff.replace('\r', '') - diff = diff.strip() + '\n' # For keeping a buffer of lines preceding @@ ... @@ buflines = list() @@ -701,8 +700,9 @@ class LoreMessage: if pp > 0: # Inside the patch phasher.update((line + '\n').encode('utf-8')) - if line[0] != '-': - pp -= 1 + if len(line) and line[0] == '-': + continue + pp -= 1 continue # Not anything we recognize, so stick into buflines buflines.append(line) |