From 3a1af9f42425ff1dc0e5fe148d736e1523fad76f Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Thu, 14 May 2020 13:27:04 +0200 Subject: [PATCH] fall back for UnicodeDecodeError --- app/email_utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/email_utils.py b/app/email_utils.py index 582d1aa1..7dc60a03 100644 --- a/app/email_utils.py +++ b/app/email_utils.py @@ -503,7 +503,11 @@ def parseaddr_unicode(addr) -> (str, str): name = name.strip() decoded_string, charset = decode_header(name)[0] if charset is not None: - name = decoded_string.decode(charset) + try: + name = decoded_string.decode(charset) + except UnicodeDecodeError: + LOG.warning("Cannot decode addr name %s", name) + name = "" else: name = decoded_string