]> git.droids-corp.org - imapami.git/commitdiff
utils: fix exception with bad encoding
authorOlivier Matz <zer0@droids-corp.org>
Sun, 27 Nov 2016 14:38:39 +0000 (15:38 +0100)
committerOlivier Matz <olivier.matz@6wind.com>
Mon, 28 Nov 2016 09:51:16 +0000 (10:51 +0100)
Do not be strict when converting to unicode from an unknown encoding.
This avoids an unrecoverable exception.

Signed-off-by: Olivier Matz <zer0@droids-corp.org>
imapami/utils.py

index 4af970c091406180df5e6b22276818a45e540f5a..375910ce6fc8de29e4120c13d41a4d4e811231c8 100644 (file)
@@ -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