1
0
Fork 0

Revamping encoding handling to normalize encodings to UTF-8 for storage; back into original encoding during rehydration.

This commit is contained in:
Adam Coddington 2013-07-26 01:01:07 -07:00
parent f92e2a8448
commit 2e6c23a6f0
3 changed files with 48 additions and 14 deletions

View file

@ -55,11 +55,3 @@ X-Mailer: Seven Enterprise Gateway (v 2.0)
This message contains funny UTF16 characters like this one: " " and this one "✿".
-----Original Message-----
Date: Wednesday, December 26, 2012 1:53:27 pm
To: user2@yahoo.com
From: "Person" <user3@example.com>
Subject: Fwd: Stuff
Person -
etc...

View file

@ -109,3 +109,25 @@ class TestProcessEmail(EmailMessageTestCase):
expected_body,
actual_body
)
def test_message_with_misplaced_utf8_content(self):
""" Ensure that we properly handle incorrectly encoded messages
``message_with_utf8_char.eml``'s primary text payload is marked
as being iso-8859-1 data, but actually contains UTF-8 bytes.
"""
email_object = self._get_email_object('message_with_utf8_char.eml')
msg = self.mailbox.process_incoming_message(email_object)
actual_text = msg.get_text_body()
expected_text = (
u'This message contains funny UTF16 characters like this one: '
u'"\xc2\xa0" and this one "\xe2\x9c\xbf".'
)
self.assertEqual(
expected_text,
actual_text,
)