From aaed875ecce770bde03a2066ade40944cd1ab31d Mon Sep 17 00:00:00 2001 From: NavaL Date: Fri, 21 Oct 2016 21:11:22 +0200 Subject: [#797] reinstating use of the provided email body charstet encoding --- service/pixelated/adapter/mailstore/body_parser.py | 5 +++-- service/pixelated/adapter/mailstore/leap_mailstore.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'service/pixelated/adapter') 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()) -- cgit v1.2.3