diff options
author | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-09-09 16:37:48 +0200 |
---|---|---|
committer | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-09-09 16:37:48 +0200 |
commit | 7f5c0ec1424ac629c4ab60d72ff9b1a3717fb4c8 (patch) | |
tree | ab563364fdb6268df357428a21ec173651d4ad22 /service/test/unit/adapter/mailstore/test_body_parser.py | |
parent | 72e681fe1ccf98b5de50d54928ba1d2e996c29da (diff) |
Improved body decoding when parsing mails.
- Issue #450
- does not fix 8bit encoded bodies - special chars are replaced before
we are in pixelated code
Diffstat (limited to 'service/test/unit/adapter/mailstore/test_body_parser.py')
-rw-r--r-- | service/test/unit/adapter/mailstore/test_body_parser.py | 18 |
1 files changed, 18 insertions, 0 deletions
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()) |