handle utf-8 decoding fail

This commit is contained in:
Son Nguyen Kim 2021-09-08 15:17:11 +02:00
parent 5ac78f2694
commit 4df83f953d
1 changed files with 6 additions and 1 deletions

View File

@ -699,7 +699,12 @@ def parseaddr_unicode(addr) -> (str, str):
LOG.w(
"Cannot decode %s with %s, use utf-8", decoded_string, charset
)
name = decoded_string.decode("utf-8")
try:
name = decoded_string.decode("utf-8")
except UnicodeDecodeError:
LOG.w("utf-8 not work on %s", decoded_string)
name = ""
else:
name = decoded_string