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.
This commit is contained in:
Adam Niederer
2017-01-27 23:51:32 -05:00
committed by GitHub
parent d792a28254
commit ba913fe31d

View File

@@ -116,7 +116,7 @@ def decode_content(message):
content = message.get_payload(decode=True) content = message.get_payload(decode=True)
charset = message.get_content_charset('utf-8') charset = message.get_content_charset('utf-8')
try: try:
return content.decode(charset) return content.decode(charset, 'ignore')
except AttributeError: except AttributeError:
return content return content