From 178fe8b2066496963aa170f3695c67a998e4f5bd Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Wed, 9 Dec 2020 17:48:51 -0500 Subject: Only check allow-list of trailers in follow-ups We only need to check against the list of known non-person trailers if we're looking at follow-up messages. Any trailers we see in the actual commit messages can be taken at their face value. Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/b4/__init__.py b/b4/__init__.py index 730cefc..795ebb6 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -887,10 +887,10 @@ class LoreMessage: # We only pay attention to trailers that are sent in reply if self.reply: - trailers, others = LoreMessage.find_trailers(self.body) + trailers, others = LoreMessage.find_trailers(self.body, followup=True) for trailer in trailers: # These are commonly part of patch/commit metadata - badtrailers = ('from', 'author', 'cc') + badtrailers = ('from', 'author', 'cc', 'to') if trailer[0].lower() not in badtrailers: self.trailers.append(trailer) @@ -1194,8 +1194,8 @@ class LoreMessage: self.attestation = LoreAttestation(i, m, p) @staticmethod - def find_trailers(body): - headers = ('subject', 'date', 'from', 'to') + def find_trailers(body, followup=False): + headers = ('subject', 'date', 'from') nonperson = ('fixes', 'subject', 'date', 'link', 'buglink') # Fix some more common copypasta trailer wrapping # Fixes: abcd0123 (foo bar @@ -1222,10 +1222,11 @@ class LoreMessage: if len(others) and tname in headers: logger.debug('Ignoring %s (header after other content)', line) continue - mperson = re.search(r'\S+@\S+\.\S+', groups[1]) - if not mperson and tname not in nonperson: - logger.debug('Ignoring %s (not a recognized non-person trailer)', line) - continue + if followup: + mperson = re.search(r'\S+@\S+\.\S+', groups[1]) + if not mperson and tname not in nonperson: + logger.debug('Ignoring %s (not a recognized non-person trailer)', line) + continue was_trailer = True groups.append(None) trailers.append(groups) -- cgit v1.2.3