From ba913fe31dd6146f9500583916d4332edce1c481 Mon Sep 17 00:00:00 2001 From: Adam Niederer Date: Fri, 27 Jan 2017 23:51:32 -0500 Subject: [PATCH] Permissively Decode Emails Email providers throw all kinds of garbage in their emails - even Gmail and Thunderbird send invalid UTF-8 in certain cases. Not throwing UnicodeErrors every time an email provider screws up their UTF-8 would really help QOL when using this library. --- imbox/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imbox/parser.py b/imbox/parser.py index 1def6e5..9d83fe3 100644 --- a/imbox/parser.py +++ b/imbox/parser.py @@ -116,7 +116,7 @@ def decode_content(message): content = message.get_payload(decode=True) charset = message.get_content_charset('utf-8') try: - return content.decode(charset) + return content.decode(charset, 'ignore') except AttributeError: return content