From 71d4662c7b9f829e927b259529f65371f27079d5 Mon Sep 17 00:00:00 2001 From: Timothy Hobbs Date: Tue, 26 Mar 2019 14:50:45 +0100 Subject: [PATCH] Fix #732 encoding of 8bit utf emails --- helpdesk/email.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/helpdesk/email.py b/helpdesk/email.py index 9bf442f2..483d96b1 100644 --- a/helpdesk/email.py +++ b/helpdesk/email.py @@ -471,9 +471,12 @@ def object_from_message(message, queue, logger): if part.get_content_maintype() == 'text' and name is None: if part.get_content_subtype() == 'plain': - body = EmailReplyParser.parse_reply( - decodeUnknown(part.get_content_charset(), part.get_payload(decode=True)) - ) + body = part.get_payload(decode=True) + # https://github.com/django-helpdesk/django-helpdesk/issues/732 + if part['Content-Transfer-Encoding'] == '8bit' and part.get_content_charset() == 'utf-8': + body = body.decode('unicode_escape') + body = decodeUnknown(part.get_content_charset(), body) + body = EmailReplyParser.parse_reply(body) # workaround to get unicode text out rather than escaped text try: body = body.encode('ascii').decode('unicode_escape')