From 367be74dfd02735cc989258d1a58ce05a8ebc886 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Thu, 19 Mar 2020 21:48:32 -0400 Subject: 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 Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 6 +++--- 1 file 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) -- cgit v1.2.3