mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 03:41:05 -05:00
Inbound: fix 8bit Unicode parsing as escape sequences on Python 3
Work around Python 3 email parser change that can turn Unicode characters into \u escape sequences when parsing a message (or attachment) that uses "Content-Transfer-Encoding: 8bit".
This commit is contained in:
@@ -199,6 +199,10 @@ class AnymailInboundMessage(Message, object): # `object` ensures new-style clas
|
||||
@classmethod
|
||||
def parse_raw_mime(cls, s):
|
||||
"""Returns a new AnymailInboundMessage parsed from str s"""
|
||||
if isinstance(s, six.text_type):
|
||||
# Avoid Python 3.x issue https://bugs.python.org/issue18271
|
||||
# (See test_inbound: test_parse_raw_mime_8bit_utf8)
|
||||
return cls.parse_raw_mime_bytes(s.encode('utf-8'))
|
||||
return EmailParser(cls).parsestr(s)
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user