1
0
Fork 0

Interpret unknown encodings as ASCII. Fixes #34.

This commit is contained in:
Adam Coddington 2014-11-15 22:15:25 -08:00
parent e1b0763a46
commit aa59199c9b
4 changed files with 64 additions and 15 deletions

View file

@ -299,6 +299,17 @@ class Mailbox(models.Model):
# defined charset, if it can't, let's mash some things
# inside the payload :-\
msg.get_payload(decode=True).decode(content_charset)
except LookupError:
logger.exception(
"Unknown encoding %s; interpreting as ascii!",
content_charset
)
msg.set_payload(
msg.get_payload(decode=True).decode(
'ascii',
'ignore'
)
)
except UnicodeDecodeError:
msg.set_payload(
msg.get_payload(decode=True).decode(