Commit 8ba61613 authored by Nicolas Delaby's avatar Nicolas Delaby

Handle case when no encoding is detected

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21112 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e8e40e2e
......@@ -265,13 +265,13 @@ class EmailDocument(File, TextDocument):
for part in self._getMessage().walk():
if part.get_content_type() == 'text/plain' and not text_result and not part.is_multipart():
part_encoding = part.get_content_charset()
if part_encoding != 'utf-8':
if part_encoding not in (None, 'utf-8',):
text_result = part.get_payload(decode=1).decode(part_encoding).encode('utf-8')
else:
text_result = part.get_payload(decode=1)
elif part.get_content_type() == 'text/html' and not html_result and not part.is_multipart():
part_encoding = part.get_content_charset()
if part_encoding != 'utf-8':
if part_encoding not in (None, 'utf-8',):
return part.get_payload(decode=1).decode(part_encoding).encode('utf-8')
return part.get_payload(decode=1)
return text_result
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment