mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-10 06:48:19 +02:00
Interpret unknown encodings as ASCII. Fixes #34.
This commit is contained in:
parent
e1b0763a46
commit
aa59199c9b
4 changed files with 64 additions and 15 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue