Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-113594: email roundtrip #113639

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions Lib/test/test_email/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,23 @@ def test_as_bytes_policy(self):
g.flatten(msg)
self.assertEqual(fullrepr, s.getvalue())

def test_roundtrip(self) -> None:
"""Tests for gh-113594 to check that a message can be roundtripped
without crashing or losing information.
"""
email_raw_1 = \
b'Content-Type: multipart/mixed; boundary="==="\n\n--===\n' + \
b'Content-Type: message/plain\n \n \xe6\x82\xa80123456789012.3456789\n' + \
b'\n--===--\n'
email_raw_2 = b'Content-Type: multipart/mixed; boundary="==="\n\n--===\n' + \
b'Content-Type: message/plain\n \n \xe6\x82\xa80123456789012.34567890\n' + \
b'\n--===--\n'

message_1 = email.message_from_bytes(email_raw_1, policy=email.policy.SMTPUTF8)
print(message_1)
message_2 = email.message_from_bytes(email_raw_2, policy=email.policy.SMTPUTF8)
print(message_2)

# test_headerregistry.TestContentTypeHeader.bad_params
def test_bad_param(self):
msg = email.message_from_string("Content-Type: blarg; baz; boo\n")
Expand Down