aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2021-04-14 16:12:35 +0200
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2021-04-15 11:04:17 -0400
commit21a3a883974f0bc9569aef0fcc6e14706b810f31 (patch)
tree48f5850edc2f0cd2d68a905507312bd7922f9e99
parentbade6f603831c88ce54eed656f453d1101402451 (diff)
downloadkorg-helpers-21a3a883974f0bc9569aef0fcc6e14706b810f31.tar.gz
list-archive-maker: better handle mails with misencoded real names
Without this change list-archive-maker just dies with an Exception Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org> Link: https://lore.kernel.org/r/20210414141235.26630-2-u.kleine-koenig@pengutronix.de
-rwxr-xr-xlist-archive-maker.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/list-archive-maker.py b/list-archive-maker.py
index b405019..eed4807 100755
--- a/list-archive-maker.py
+++ b/list-archive-maker.py
@@ -62,6 +62,13 @@ WANTHDRS = {'return-path',
__VERSION__ = '2.0'
+def formataddr(pair):
+ try:
+ return email.utils.formataddr(pair)
+ except UnicodeEncodeError:
+ # This might happen if the realname is encoded in a broken way; just
+ # drop the real name then.
+ return email.utils.formataddr((None, pair[1]))
def process_archives(sources, outdir, msgids, listids, rejectsfile):
outboxes = {}
@@ -199,14 +206,14 @@ def process_archives(sources, outdir, msgids, listids, rejectsfile):
if pair[1] in cc:
# already in Cc, so no need to add it to To
continue
- to.append(email.utils.formataddr(pair))
+ to.append(formataddr(pair))
elif lhdrname == 'cc':
for pair in email.utils.getaddresses([hdrval]):
if pair[1] in to:
# already in To, so no need to add it to CCs
continue
- cc.append(email.utils.formataddr(pair))
+ cc.append(formataddr(pair))
else:
newhdrs.append((hdrname, hdrval))