From 7f5c0ec1424ac629c4ab60d72ff9b1a3717fb4c8 Mon Sep 17 00:00:00 2001 From: Folker Bernitt Date: Wed, 9 Sep 2015 16:37:48 +0200 Subject: Improved body decoding when parsing mails. - Issue #450 - does not fix 8bit encoded bodies - special chars are replaced before we are in pixelated code --- .../test/unit/adapter/mailstore/test_body_parser.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'service/test/unit/adapter/mailstore') diff --git a/service/test/unit/adapter/mailstore/test_body_parser.py b/service/test/unit/adapter/mailstore/test_body_parser.py index eeb1a2ed..3c2d17fb 100644 --- a/service/test/unit/adapter/mailstore/test_body_parser.py +++ b/service/test/unit/adapter/mailstore/test_body_parser.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # # Copyright (c) 2015 ThoughtWorks, Inc. # @@ -28,3 +29,20 @@ class BodyParserTest(unittest.TestCase): parser = BodyParser('dGVzdCB0ZXh0\n', content_type='text/plain; charset="utf-8"', content_transfer_encoding='base64') self.assertEqual('test text', parser.parsed_content()) + + def test_8bit_transfer_encoding_with_iso_8859_1_str_input(self): + data = 'Hmm, here are \xdcml\xe4\xfcts again!' + parser = BodyParser(data, content_type='text/plain; charset=iso-8859-1', content_transfer_encoding='8bit') + + self.assertEqual(u'Hmm, here are Ümläüts again!', parser.parsed_content()) + + def test_8bit_transfer_encoding_with_iso_8859_1_unicode_input(self): + data = u'Hmm, here are \xdcml\xe4\xfcts again!' + parser = BodyParser(data, content_type='text/plain; charset=iso-8859-1', content_transfer_encoding='8bit') + + self.assertEqual(u'Hmm, here are Ümläüts again!', parser.parsed_content()) + + def test_base64_with_default_us_ascii_encoding(self): + parser = BodyParser('dGVzdCB0ZXh0\n', content_type='text/plain', content_transfer_encoding='base64') + + self.assertEqual('test text', parser.parsed_content()) -- cgit v1.2.3