From 5b8da0ce53fb6e1b2efed0906381a313d95b3778 Mon Sep 17 00:00:00 2001 From: Folker Bernitt Date: Thu, 5 Mar 2015 16:45:47 +0100 Subject: Fixed problem when doding mails and with non utf-8 charset. --- service/pixelated/adapter/model/mail.py | 2 +- service/test/unit/adapter/test_mail.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'service') diff --git a/service/pixelated/adapter/model/mail.py b/service/pixelated/adapter/model/mail.py index f912680f..951e6a21 100644 --- a/service/pixelated/adapter/model/mail.py +++ b/service/pixelated/adapter/model/mail.py @@ -82,7 +82,7 @@ class Mail(object): def _parse_charset_header(self, charset_header, default_charset='utf-8'): try: - return re.compile('.*charset=(.*);').match(charset_header).group(1) + return re.compile('.*charset=([a-zA-Z0-9-]+)').match(charset_header).group(1) except: return default_charset diff --git a/service/test/unit/adapter/test_mail.py b/service/test/unit/adapter/test_mail.py index 54c421c7..ed7b945a 100644 --- a/service/test/unit/adapter/test_mail.py +++ b/service/test/unit/adapter/test_mail.py @@ -174,9 +174,9 @@ class TestPixelatedMail(unittest.TestCase): self.assertRegexpMatches(mail.html_body, '([\s\S]*100%)') def test_content_type_header_of_mail_part_is_used(self): - plain_headers = {'Content-Type': 'text/plain; charset=utf-8', 'Content-Transfer-Encoding': 'quoted-printable'} + plain_headers = {'Content-Type': 'text/plain; charset=iso-8859-1', 'Content-Transfer-Encoding': 'quoted-printable'} html_headers = {'Content-Type': 'text/html; charset=utf-8', 'Content-Transfer-Encoding': 'quoted-printable'} - parts = {'alternatives': [{'content': 'H=C3=A4llo', 'headers': plain_headers}, {'content': '

H=C3=A4llo

', 'headers': html_headers}]} + parts = {'alternatives': [{'content': 'H=E4llo', 'headers': plain_headers}, {'content': '

H=C3=A4llo

', 'headers': html_headers}]} mail = PixelatedMail.from_soledad(None, None, self._create_bdoc(raw='some raw body'), parts=parts, soledad_querier=None) -- cgit v1.2.3