diff options
author | Arkadiusz Hiler <arek.l1@gmail.com> | 2020-05-14 00:53:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-14 00:53:26 (GMT) |
commit | 6f2f475d5a2cd7675dce844f3af436ba919ef92b (patch) | |
tree | a716eac3e0f40024c90214076998a3b8a4b6609c /Lib/test/test_email | |
parent | 3d17c045b4c3d09b72bbd95ed78af1ae6f0d98d2 (diff) | |
download | cpython-6f2f475d5a2cd7675dce844f3af436ba919ef92b.zip cpython-6f2f475d5a2cd7675dce844f3af436ba919ef92b.tar.gz cpython-6f2f475d5a2cd7675dce844f3af436ba919ef92b.tar.bz2 |
bpo-40597: email: Use CTE if lines are longer than max_line_length consistently (gh-20038)
raw_data_manager (default for EmailPolicy, EmailMessage)
does correct wrapping of 'text' parts as long as the message contains
characters outside of 7bit US-ASCII set: base64 or qp
Content-Transfer-Encoding is applied if the lines would be too long
without it. It did not, however, do this for ascii-only text,
which could result in lines that were longer than
policy.max_line_length or even the rfc 998 maximum.
This changeset fixes the heuristic so that if lines are longer than
policy.max_line_length, it will always apply a
content-transfer-encoding so that the lines are wrapped correctly.
Diffstat (limited to 'Lib/test/test_email')
-rw-r--r-- | Lib/test/test_email/test_contentmanager.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_email/test_contentmanager.py b/Lib/test/test_email/test_contentmanager.py index 169058e..64dca2d 100644 --- a/Lib/test/test_email/test_contentmanager.py +++ b/Lib/test/test_email/test_contentmanager.py @@ -329,6 +329,21 @@ class TestRawDataManager(TestEmailBase): self.assertEqual(m.get_payload(decode=True).decode('utf-8'), content) self.assertEqual(m.get_content(), content) + def test_set_text_plain_long_line_heuristics(self): + m = self._make_message() + content = ("Simple but long message that is over 78 characters" + " long to force transfer encoding.\n") + raw_data_manager.set_content(m, content) + self.assertEqual(str(m), textwrap.dedent("""\ + Content-Type: text/plain; charset="utf-8" + Content-Transfer-Encoding: quoted-printable + + Simple but long message that is over 78 characters long to = + force transfer encoding. + """)) + self.assertEqual(m.get_payload(decode=True).decode('utf-8'), content) + self.assertEqual(m.get_content(), content) + def test_set_text_short_line_minimal_non_ascii_heuristics(self): m = self._make_message() content = "et là il est monté sur moi et il commence à m'éto.\n" |