diff options
author | Sidney Markowitz <sidney@sidney.com> | 2023-12-11 16:21:18 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-11 16:21:18 (GMT) |
commit | 27a5fd8cb8c88537216d7a498eba9d9177951d76 (patch) | |
tree | 4bb61ba73e6039abd3947528596f08ef9671a645 /Lib/test/test_email | |
parent | 3251ba8f1af535bf28e31a6832511ba19e96b262 (diff) | |
download | cpython-27a5fd8cb8c88537216d7a498eba9d9177951d76.zip cpython-27a5fd8cb8c88537216d7a498eba9d9177951d76.tar.gz cpython-27a5fd8cb8c88537216d7a498eba9d9177951d76.tar.bz2 |
gh-94606: Fix error when message with Unicode surrogate not surrogateescaped string (GH-94641)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/test/test_email')
-rw-r--r-- | Lib/test/test_email/test_message.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Lib/test/test_email/test_message.py b/Lib/test/test_email/test_message.py index d3f396f..034f762 100644 --- a/Lib/test/test_email/test_message.py +++ b/Lib/test/test_email/test_message.py @@ -748,6 +748,35 @@ class TestEmailMessageBase: self.assertEqual(len(list(m.iter_attachments())), 2) self.assertEqual(m.get_payload(), orig) + get_payload_surrogate_params = { + + 'good_surrogateescape': ( + "String that can be encod\udcc3\udcabd with surrogateescape", + b'String that can be encod\xc3\xabd with surrogateescape' + ), + + 'string_with_utf8': ( + "String with utf-8 charactër", + b'String with utf-8 charact\xebr' + ), + + 'surrogate_and_utf8': ( + "String that cannot be ëncod\udcc3\udcabd with surrogateescape", + b'String that cannot be \xebncod\\udcc3\\udcabd with surrogateescape' + ), + + 'out_of_range_surrogate': ( + "String with \udfff cannot be encoded with surrogateescape", + b'String with \\udfff cannot be encoded with surrogateescape' + ), + } + + def get_payload_surrogate_as_gh_94606(self, msg, expected): + """test for GH issue 94606""" + m = self._str_msg(msg) + payload = m.get_payload(decode=True) + self.assertEqual(expected, payload) + class TestEmailMessage(TestEmailMessageBase, TestEmailBase): message = EmailMessage |