mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-21 23:43:11 +01:00
Fix decoding of plain text emails in non-utf8 encodings such as koi8-r. Thanks to Sergey Kirillov for the patch, which fixes Github issue #9 and Google Code issue #150.
This commit is contained in:
parent
b68bd73d07
commit
8f15febe23
@ -130,11 +130,10 @@ def process_queue(q, quiet=False):
|
||||
def decodeUnknown(charset, string):
|
||||
if not charset:
|
||||
try:
|
||||
string = string.decode('utf-8')
|
||||
return string.decode('utf-8')
|
||||
except:
|
||||
string = string.decode('iso8859-1')
|
||||
string = unicode(string)
|
||||
return string
|
||||
return string.decode('iso8859-1')
|
||||
return unicode(string)
|
||||
|
||||
def decode_mail_headers(string):
|
||||
decoded = decode_header(string)
|
||||
@ -181,7 +180,7 @@ def ticket_from_message(message, queue, quiet):
|
||||
|
||||
if part.get_content_maintype() == 'text' and name == None:
|
||||
if part.get_content_subtype() == 'plain':
|
||||
body_plain = decodeUnknown(part.get_charset(), part.get_payload(decode=True))
|
||||
body_plain = decodeUnknown(part.get_content_charset(), part.get_payload(decode=True))
|
||||
else:
|
||||
body_html = part.get_payload(decode=True)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user