diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-11-27 10:52:09 -0500 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-11-27 10:52:09 -0500 |
commit | fa9a573b428dd8e8ce67e4ab0a2c28111ec7988d (patch) | |
tree | 5394a270ea1b5c55d31b295bcd3022cbbcb4cfa0 | |
parent | 2fbfda8826f449a25c1c1f84b6b6933b2b900f04 (diff) | |
download | korg-helpers-fa9a573b428dd8e8ce67e4ab0a2c28111ec7988d.tar.gz |
Don't demangle From: if it's not mangled
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rwxr-xr-x | list-archive-collector.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/list-archive-collector.py b/list-archive-collector.py index 328e988..f122e27 100755 --- a/list-archive-collector.py +++ b/list-archive-collector.py @@ -350,12 +350,13 @@ def grab_pipermail_archive(pipermail_url, mbx, listid, toaddr, lookaside, checks tmpmbx = mailbox.mbox(tmpfile) for msg in tmpmbx: logger.info(' processing: %s', msg.get('Message-Id')) - # Fix bogus From: foo@bar.baz (Foo Barski) -> Foo Barski <foo@bar.baz> - fromline = msg.get('From', '') - matches = re.search(r'(\S+@\S+\.\S+) \((.*)\)$', fromline) - if matches: - gr = matches.groups() - msg.replace_header('From', f'{gr[1]} <{gr[0]}>') + fromline = msg.get('From') + if fromline and fromline.find('(') > 0: + # Fix bogus From: foo@bar.baz (Foo Barski) -> Foo Barski <foo@bar.baz> + matches = re.search(r'(\S+@\S+\.\S+) \((.*)\)$', fromline) + if matches: + gr = matches.groups() + msg.replace_header('From', f'{gr[1]} <{gr[0]}>') if listid: msg['List-Id'] = f'<{listid}>' |