summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/pixelated/adapter/model/mail.py1
-rw-r--r--service/test/unit/adapter/test_mail.py20
2 files changed, 20 insertions, 1 deletions
diff --git a/service/pixelated/adapter/model/mail.py b/service/pixelated/adapter/model/mail.py
index 85f2bed4..c0fdcab6 100644
--- a/service/pixelated/adapter/model/mail.py
+++ b/service/pixelated/adapter/model/mail.py
@@ -289,7 +289,6 @@ class PixelatedMail(Mail):
_headers[header] = [head.strip() for head in compact(_headers[header])]
for header in ['From', 'Subject']:
- # _headers[header] = hdoc_headers.get(header)
_headers[header] = self._decode_header(hdoc_headers.get(header))
_headers['Date'] = self._get_date()
diff --git a/service/test/unit/adapter/test_mail.py b/service/test/unit/adapter/test_mail.py
index 87fbecc1..fc0861d6 100644
--- a/service/test/unit/adapter/test_mail.py
+++ b/service/test/unit/adapter/test_mail.py
@@ -303,6 +303,26 @@ class TestPixelatedMail(unittest.TestCase):
self.content = {'raw': raw}
return FakeBDoc(raw)
+ def test_encoding_special_character_on_header(self):
+ subject = "=?UTF-8?Q?test_encoding_St=C3=A4ch?="
+ email_from = "=?UTF-8?Q?St=C3=A4ch_<stach@pixelated-project.org>?="
+
+ pixel_mail = PixelatedMail()
+
+ self.assertEqual(pixel_mail._decode_header(subject), 'test encoding St\xc3\xa4ch')
+ self.assertEqual(pixel_mail._decode_header(email_from), 'St\xc3\xa4ch <stach@pixelated-project.org>')
+
+ def test_headers_are_encoded_right(self):
+ subject = "=?UTF-8?Q?test_encoding_St=C3=A4ch?="
+ email_from = "=?UTF-8?Q?St=C3=A4ch_<stach@pixelated-project.org>?="
+
+ leap_mail = test_helper.leap_mail(extra_headers={'Subject': subject, 'From': email_from})
+
+ mail = PixelatedMail.from_soledad(*leap_mail, soledad_querier=self.querier)
+
+ self.assertEqual(str(mail.headers['Subject']), 'test encoding St\xc3\xa4ch')
+ self.assertEqual(str(mail.headers['From']), 'St\xc3\xa4ch <stach@pixelated-project.org>')
+
class InputMailTest(unittest.TestCase):
mail_dict = lambda x: {