From 8e1a6b30fa02f9088d8f3828249ab2e2395b2180 Mon Sep 17 00:00:00 2001 From: Garret Wassermann Date: Sun, 16 Apr 2017 04:59:57 -0400 Subject: [PATCH] Fix encoding first before splitting strings, so it works on Python 2 --- helpdesk/management/commands/get_email.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/helpdesk/management/commands/get_email.py b/helpdesk/management/commands/get_email.py index aa66a52f..3fa3d38a 100644 --- a/helpdesk/management/commands/get_email.py +++ b/helpdesk/management/commands/get_email.py @@ -276,11 +276,13 @@ def ticket_from_message(message, queue, logger): cc = message.get_all('cc', None) if cc: + # first, fixup the encoding if necessary + cc = [decode_mail_headers(decodeUnknown(message.get_charset(), x)) for x in cc] # get_all checks if multiple CC headers, but individual emails may be comma separated too tempcc = [] for hdr in cc: tempcc.extend(hdr.split(',')) - cc = [decode_mail_headers(decodeUnknown(message.get_charset(), x.strip())) for x in tempcc] + cc = [x.strip() for x in tempcc] for ignore in IgnoreEmail.objects.filter(Q(queues=queue) | Q(queues__isnull=True)): if ignore.test(sender_email):