From: Olivier Matz Date: Sun, 27 Nov 2016 14:38:39 +0000 (+0100) Subject: utils: fix exception with bad encoding X-Git-Url: http://git.droids-corp.org/?p=imapami.git;a=commitdiff_plain;h=1057fcec8ac1e8c77836b561746bdbc9b9de2725 utils: fix exception with bad encoding Do not be strict when converting to unicode from an unknown encoding. This avoids an unrecoverable exception. Signed-off-by: Olivier Matz --- diff --git a/imapami/utils.py b/imapami/utils.py index 4af970c..375910c 100644 --- a/imapami/utils.py +++ b/imapami/utils.py @@ -74,7 +74,7 @@ def headers_to_unicode(headers): # fallback to wrong decoding value, encoding = hdr, 'utf-8' if encoding is None: - value = unicode(value) + value = unicode(value, errors="replace") else: value = value.decode(encoding, errors="replace") unicode_headers[key] = value