aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-03-09 12:35:27 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2020-03-09 12:35:27 -0400
commit41d9210c37833bedd6e357eaf23a81d120493bdd (patch)
treeba28f813be24cd098a4bcdc3acc76fb61d241273
parent84df4e5487b9c3e131774ae6bf3c50794b822265 (diff)
downloadkorg-helpers-41d9210c37833bedd6e357eaf23a81d120493bdd.tar.gz
Relax trailer sanity-checking to match by name
We reject trailers that don't match the email address in the From: field, but this can be too strict for our purposes. Relax the rule to also allow matching by name. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rwxr-xr-xget-lore-mbox.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/get-lore-mbox.py b/get-lore-mbox.py
index 572bc43..5160fb5 100755
--- a/get-lore-mbox.py
+++ b/get-lore-mbox.py
@@ -428,16 +428,17 @@ class LoreMessage:
# Do we have something that looks like a person-trailer?
matches = re.findall(r'^\s*([\w-]+):[ \t]+(.*<\S+>)\s*$', self.body, re.MULTILINE)
if matches:
- # Does the email in the trailer match what's in the From?
+ # Basic sanity checking -- the trailer must match the name or the email
+ # in the From header, to avoid false-positive trailer parsing errors
for tname, tvalue in matches:
namedata = email.utils.getaddresses([tvalue])[0]
tfrom = re.sub(r'\+[^@]+@', '@', namedata[1].lower())
hfrom = re.sub(r'\+[^@]+@', '@', self.fromemail.lower())
- if tfrom == hfrom:
+ if tfrom == hfrom or namedata[0].lower() == self.fromname.lower():
self.trailers.append((tname, tvalue))
else:
- logger.debug(' ignoring "%s: %s" due to from mismatch (from: %s)', tname, tvalue,
- self.fromemail)
+ logger.debug(' ignoring "%s: %s" due to from mismatch (from: %s %s)', tname, tvalue,
+ self.fromname, self.fromemail)
def __repr__(self):
out = list()