mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-22 07:53:19 +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):
|
def decodeUnknown(charset, string):
|
||||||
if not charset:
|
if not charset:
|
||||||
try:
|
try:
|
||||||
string = string.decode('utf-8')
|
return string.decode('utf-8')
|
||||||
except:
|
except:
|
||||||
string = string.decode('iso8859-1')
|
return string.decode('iso8859-1')
|
||||||
string = unicode(string)
|
return unicode(string)
|
||||||
return string
|
|
||||||
|
|
||||||
def decode_mail_headers(string):
|
def decode_mail_headers(string):
|
||||||
decoded = decode_header(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_maintype() == 'text' and name == None:
|
||||||
if part.get_content_subtype() == 'plain':
|
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:
|
else:
|
||||||
body_html = part.get_payload(decode=True)
|
body_html = part.get_payload(decode=True)
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user