mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-09 22:38:19 +02:00
Improve the workaround of https://bugs.python.org/issue27321 in coddingtonbear#136.
Attempt to use patch from https://bugs.python.org/msg308362.
This commit is contained in:
parent
26786a0b32
commit
cdda047f9f
1 changed files with 7 additions and 2 deletions
|
|
@ -372,8 +372,13 @@ class Mailbox(models.Model):
|
||||||
except KeyError as exc:
|
except KeyError as exc:
|
||||||
# email.message.replace_header may raise 'KeyError' if the header
|
# email.message.replace_header may raise 'KeyError' if the header
|
||||||
# 'content-transfer-encoding' is missing
|
# 'content-transfer-encoding' is missing
|
||||||
logger.warning("Failed to parse message: %s", exc,)
|
try:
|
||||||
return None
|
# Before we give up, let's try mailman's approach:
|
||||||
|
# https://bugs.python.org/msg308362
|
||||||
|
body = message.as_bytes(self).decode('ascii', 'replace')
|
||||||
|
except KeyError as exc:
|
||||||
|
logger.warning("Failed to parse message: %s", exc,)
|
||||||
|
return None
|
||||||
msg.set_body(body)
|
msg.set_body(body)
|
||||||
if message['in-reply-to']:
|
if message['in-reply-to']:
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue