mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
gh-76511: Fix email.Message.as_string() for non-ASCII message with ASCII charset (GH-116125)
This commit is contained in:
parent
df59401108
commit
f97f25ef5d
4 changed files with 21 additions and 2 deletions
|
@ -337,6 +337,21 @@ class TestMessageAPI(TestEmailBase):
|
|||
msg = email.message_from_bytes(source)
|
||||
self.assertEqual(msg.as_string(), expected)
|
||||
|
||||
def test_nonascii_as_string_with_ascii_charset(self):
|
||||
m = textwrap.dedent("""\
|
||||
MIME-Version: 1.0
|
||||
Content-type: text/plain; charset="us-ascii"
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Test if non-ascii messages with no Content-Transfer-Encoding set
|
||||
can be as_string'd:
|
||||
Föö bär
|
||||
""")
|
||||
source = m.encode('iso-8859-1')
|
||||
expected = source.decode('ascii', 'replace')
|
||||
msg = email.message_from_bytes(source)
|
||||
self.assertEqual(msg.as_string(), expected)
|
||||
|
||||
def test_nonascii_as_string_without_content_type_and_cte(self):
|
||||
m = textwrap.dedent("""\
|
||||
MIME-Version: 1.0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue