From 5e9fed2d46d9bf848b65adea1846e2d214210cf5 Mon Sep 17 00:00:00 2001 From: Timothy Hobbs Date: Sat, 9 Mar 2019 00:00:32 +0100 Subject: [PATCH] Add failing test for #732 --- helpdesk/tests/test_files/all-special-chars.eml | 15 +++++++++++++++ helpdesk/tests/test_get_email.py | 13 ++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 helpdesk/tests/test_files/all-special-chars.eml diff --git a/helpdesk/tests/test_files/all-special-chars.eml b/helpdesk/tests/test_files/all-special-chars.eml new file mode 100644 index 00000000..4d922482 --- /dev/null +++ b/helpdesk/tests/test_files/all-special-chars.eml @@ -0,0 +1,15 @@ +To: helpdesk@auto-mat.cz +From: Timothy Hobbs +Subject: =?UTF-8?B?VGVzdG92w6Fjw60gZW1haWw=?= +Openpgp: preference=signencrypt +Message-ID: <0fd7067e-2842-5b6c-3548-3cf7e6a1c9ea@auto-mat.cz> +Date: Fri, 8 Mar 2019 23:40:04 +0100 +User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 + Thunderbird/60.4.0 +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: 8bit +Content-Language: en-US + +íářčšáíéřášč + diff --git a/helpdesk/tests/test_get_email.py b/helpdesk/tests/test_get_email.py index 7a4fe448..d923323c 100644 --- a/helpdesk/tests/test_get_email.py +++ b/helpdesk/tests/test_get_email.py @@ -56,7 +56,7 @@ class GetEmailCommonTests(TestCase): self.assertEqual(ticket.title, "Attachment without body") self.assertEqual(ticket.description, "") - def test_email_with_blank_body_and_attachment(self): + def test_email_with_quoted_printable_body(self): """ Tests that emails with quoted-printable bodies work. """ @@ -73,6 +73,17 @@ class GetEmailCommonTests(TestCase): attachment = attachments[0] self.assertEqual(attachment.file.read().decode("utf-8"), '
Tohle je test českých písmen odeslaných z gmailu.
\n') + def test_email_with_8bit_encoding_and_utf_8(self): + """ + Tests that emails with 8bit transfer encoding and utf-8 charset + https://github.com/django-helpdesk/django-helpdesk/issues/732 + """ + with open(os.path.join(THIS_DIR, "test_files/all-special-chars.eml")) as fd: + test_email = fd.read() + ticket = helpdesk.email.object_from_message(test_email, self.queue_public, self.logger) + self.assertEqual(ticket.title, "Testovácí email") + self.assertEqual(ticket.description, "íářčšáíéřášč") + class GetEmailParametricTemplate(object): """TestCase that checks basic email functionality across methods and socks configs."""