From 4df83f953d9d268e595d791de7524256c8dd7071 Mon Sep 17 00:00:00 2001 From: Son Nguyen Kim Date: Wed, 8 Sep 2021 15:17:11 +0200 Subject: [PATCH] handle utf-8 decoding fail --- app/email_utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/email_utils.py b/app/email_utils.py index 4eefbb6d..80153606 100644 --- a/app/email_utils.py +++ b/app/email_utils.py @@ -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