diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2019-09-03 09:41:56 +0200 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2019-09-03 09:41:56 +0200 |
commit | 9b978cc5594d93e899deac78e9415c6ce01d25f0 (patch) | |
tree | fcb3c8558c4aa4209879d683574e008434390258 | |
parent | 5d83c7a502e221ffa9f32738cc31421157c976b6 (diff) | |
download | quilttools-9b978cc5594d93e899deac78e9415c6ce01d25f0.tar.gz |
mb2q: Handle malformed discard lines gracefully
A discard line '--\n' was obviously not detected as the code was looking
for '---'.
Handle it by making the decision whether the posttag area starts by
checking whether the current line is past the last tag seen in the
text.
Reported-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rwxr-xr-x | mb2q | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -359,21 +359,26 @@ class patchmsg(object): self.posttags = '' self.has_tags = False self.has_from_in_text = False - discard_seen = False + pos = 0 + last_tagpos = 0 for l in lines: + pos += 1 if self.scan_tag(l): + last_tagpos = pos continue # Drop quoted text, except when it's '>From' - if l.startswith('>') and l.find('From') < 0: - continue + if l.startswith('>'): + if l.find('From') < 0: + continue + # Remove the quote + l = l[1:] + # Respect a From: in the body and update author if l.startswith('From:'): self.author = l.split(':')[1] self.has_from_in_text = True - if l.strip() == '---' : - discard_seen = True - if discard_seen: + if last_tagpos and pos >= last_tagpos: self.posttags += l + '\n' else: self.text += l + '\n' |