diff options
author | R David Murray <rdmurray@bitdance.com> | 2014-02-08 16:51:18 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2014-02-08 16:51:18 (GMT) |
commit | ff9616bbf7ecbd55a7206dae28f06ef90f270566 (patch) | |
tree | 9f9eb495e56d55060f76b6d3e8122d098ea1c6ce /Lib/test/test_email | |
parent | 99b1f2b3bba6cd7c2f9c78183e3275436ed0b363 (diff) | |
parent | 905c8c3d8dfe081d91e399aa5fd93d1659655264 (diff) | |
download | cpython-ff9616bbf7ecbd55a7206dae28f06ef90f270566.zip cpython-ff9616bbf7ecbd55a7206dae28f06ef90f270566.tar.gz cpython-ff9616bbf7ecbd55a7206dae28f06ef90f270566.tar.bz2 |
Merge #19772: Do not mutate message when downcoding to 7bit.
Diffstat (limited to 'Lib/test/test_email')
-rw-r--r-- | Lib/test/test_email/test_contentmanager.py | 2 | ||||
-rw-r--r-- | Lib/test/test_email/test_email.py | 12 |
2 files changed, 12 insertions, 2 deletions
diff --git a/Lib/test/test_email/test_contentmanager.py b/Lib/test/test_email/test_contentmanager.py index 1629e2d..cdb04e4 100644 --- a/Lib/test/test_email/test_contentmanager.py +++ b/Lib/test/test_email/test_contentmanager.py @@ -536,8 +536,8 @@ class TestRawDataManager(TestEmailBase): From: victim@monty.org Subject: Help Content-Type: text/plain; charset="utf-8" - MIME-Version: 1.0 Content-Transfer-Encoding: base64 + MIME-Version: 1.0 aidhaSB1biBwcm9ibMOobWUgZGUgcHl0aG9uLiBpbCBlc3Qgc29ydGkgZGUgc29uIHZpdmFyaXVt Lgo= diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py index 31fd83a..d1e234d 100644 --- a/Lib/test/test_email/test_email.py +++ b/Lib/test/test_email/test_email.py @@ -3529,7 +3529,7 @@ Here's the message body self.assertTrue(msg.get_payload(0).get_payload().endswith('\r\n')) -class Test8BitBytesHandling(unittest.TestCase): +class Test8BitBytesHandling(TestEmailBase): # In Python3 all input is string, but that doesn't work if the actual input # uses an 8bit transfer encoding. To hack around that, in email 5.1 we # decode byte streams using the surrogateescape error handler, and @@ -3782,6 +3782,16 @@ class Test8BitBytesHandling(unittest.TestCase): email.generator.Generator(out).flatten(msg) self.assertEqual(out.getvalue(), self.non_latin_bin_msg_as7bit_wrapped) + def test_str_generator_should_not_mutate_msg_when_handling_8bit(self): + msg = email.message_from_bytes(self.non_latin_bin_msg) + out = BytesIO() + BytesGenerator(out).flatten(msg) + orig_value = out.getvalue() + Generator(StringIO()).flatten(msg) # Should not mutate msg! + out = BytesIO() + BytesGenerator(out).flatten(msg) + self.assertEqual(out.getvalue(), orig_value) + def test_bytes_generator_with_unix_from(self): # The unixfrom contains a current date, so we can't check it # literally. Just make sure the first word is 'From' and the |