summaryrefslogtreecommitdiff
path: root/service/pixelated/adapter
diff options
context:
space:
mode:
authorNavaL <ayoyo@thoughtworks.com>2016-10-21 21:11:22 +0200
committerNavaL <ayoyo@thoughtworks.com>2016-10-21 21:11:22 +0200
commitaaed875ecce770bde03a2066ade40944cd1ab31d (patch)
tree8b1808dd803a1b45e1d3be394b97ac9010d9be96 /service/pixelated/adapter
parent2dcdbc47e6232309329b4ec53f5daaab201d3d5b (diff)
[#797] reinstating use of the provided email body charstet encoding
Diffstat (limited to 'service/pixelated/adapter')
-rw-r--r--service/pixelated/adapter/mailstore/body_parser.py5
-rw-r--r--service/pixelated/adapter/mailstore/leap_mailstore.py3
2 files changed, 5 insertions, 3 deletions
diff --git a/service/pixelated/adapter/mailstore/body_parser.py b/service/pixelated/adapter/mailstore/body_parser.py
index 5408bd9d..8cac75cf 100644
--- a/service/pixelated/adapter/mailstore/body_parser.py
+++ b/service/pixelated/adapter/mailstore/body_parser.py
@@ -31,13 +31,14 @@ def _parse_charset_header(content_type_and_charset_header, default_charset='us-a
class BodyParser(object):
- def __init__(self, content, content_type='text/plain; charset="us-ascii"', content_transfer_encoding=None):
+ def __init__(self, content, content_type='text/plain; charset="us-ascii"', content_transfer_encoding=None, charset=None):
self._content = content
self._content_type = content_type
self._content_transfer_encoding = content_transfer_encoding
+ self._charset = charset
def parsed_content(self):
- charset = _parse_charset_header(self._content_type)
+ charset = self._charset or _parse_charset_header(self._content_type)
text = self._serialize_for_parser(charset)
decoded_body = self._parse_and_decode(text)
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py
index 900a7cbb..288223dd 100644
--- a/service/pixelated/adapter/mailstore/leap_mailstore.py
+++ b/service/pixelated/adapter/mailstore/leap_mailstore.py
@@ -330,7 +330,8 @@ class LeapMailStore(MailStore):
parser = BodyParser('', content_type='text/plain', content_transfer_encoding='UTF-8')
# It fix the problem when leap doesn'r found body_phash and returns empty string
if not isinstance(content_doc, str):
- parser = BodyParser(content_doc.raw, content_type=content_doc.content_type, content_transfer_encoding=content_doc.content_transfer_encoding)
+ parser = BodyParser(content_doc.raw, content_type=content_doc.content_type,
+ content_transfer_encoding=content_doc.content_transfer_encoding, charset=content_doc.charset)
defer.returnValue(parser.parsed_content())