use utf-8 when unknown charset in parseaddr_unicode()

This commit is contained in:
Son NK 2020-11-18 10:03:58 +01:00
parent 28d42a7a22
commit 0963049d1f
1 changed files with 5 additions and 0 deletions

View File

@ -630,6 +630,11 @@ def parseaddr_unicode(addr) -> (str, str):
except UnicodeDecodeError:
LOG.warning("Cannot decode addr name %s", name)
name = ""
except LookupError: # charset is unknown, e.g.
LOG.exception(
"Cannot decode %s with %s, use utf-8", decoded_string, charset
)
name = decoded_string.decode("utf-8")
else:
name = decoded_string