Fix encoding first before splitting strings, so it works on Python 2

This commit is contained in:
Garret Wassermann 2017-04-16 04:59:57 -04:00
parent 7b8426596f
commit 8e1a6b30fa

View File

@ -276,11 +276,13 @@ def ticket_from_message(message, queue, logger):
cc = message.get_all('cc', None) cc = message.get_all('cc', None)
if cc: 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 # get_all checks if multiple CC headers, but individual emails may be comma separated too
tempcc = [] tempcc = []
for hdr in cc: for hdr in cc:
tempcc.extend(hdr.split(',')) 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)): for ignore in IgnoreEmail.objects.filter(Q(queues=queue) | Q(queues__isnull=True)):
if ignore.test(sender_email): if ignore.test(sender_email):