mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-08-09 08:05:13 +02:00
Fix utf decoding bug in email parsing code
For some reason mozilla thunderbird sometimes marks email parts as 8bit even though they are utf-8. I guess the best way to work around this is to add a try-catch block because this really cannot be predicted.
This commit is contained in:
@ -84,6 +84,21 @@ class GetEmailCommonTests(TestCase):
|
||||
self.assertEqual(ticket.title, "Testovácí email")
|
||||
self.assertEqual(ticket.description, "íářčšáíéřášč")
|
||||
|
||||
def test_email_with_utf_8_non_decodable_sequences(self):
|
||||
"""
|
||||
Tests that emails with utf-8 non-decodable sequences are parsed correctly
|
||||
"""
|
||||
with open(os.path.join(THIS_DIR, "test_files/utf-nondecodable.eml")) as fd:
|
||||
test_email = fd.read()
|
||||
ticket = helpdesk.email.object_from_message(test_email, self.queue_public, self.logger)
|
||||
self.assertEqual(ticket.title, "Fwd: Cyklozaměstnavatel - změna vyhodnocení")
|
||||
self.assertIn("prosazuje lepší", ticket.description)
|
||||
followups = FollowUp.objects.filter(ticket=ticket)
|
||||
followup = followups[0]
|
||||
attachments = FollowUpAttachment.objects.filter(followup=followup)
|
||||
attachment = attachments[0]
|
||||
self.assertIn('prosazuje lepší', attachment.file.read().decode("utf-8"))
|
||||
|
||||
|
||||
class GetEmailParametricTemplate(object):
|
||||
"""TestCase that checks basic email functionality across methods and socks configs."""
|
||||
|
Reference in New Issue
Block a user