forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[3.12] pythongh-80361: Fix TypeError in email.Message.get_payload() (p…
…ythonGH-117994) (pythonGH-117998) It was raised when the charset is rfc2231 encoded, e.g.: Content-Type: text/plain; charset*=ansi-x3.4-1968''utf-8 (cherry picked from commit deaecb8) Co-authored-by: Serhiy Storchaka <[email protected]>
- Loading branch information
1 parent
e95a535
commit fda8cd1
Showing
3 changed files
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4010,6 +4010,21 @@ def test_8bit_in_uuencode_body(self): | |
self.assertEqual(msg.get_payload(decode=True), | ||
'<,.V<W1A; á \n'.encode('utf-8')) | ||
|
||
def test_rfc2231_charset_8bit_CTE(self): | ||
m = textwrap.dedent("""\ | ||
From: [email protected] | ||
To: baz | ||
Mime-Version: 1.0 | ||
Content-Type: text/plain; charset*=ansi-x3.4-1968''utf-8 | ||
Content-Transfer-Encoding: 8bit | ||
pöstal | ||
""").encode('utf-8') | ||
msg = email.message_from_bytes(m) | ||
self.assertEqual(msg.get_payload(), "pöstal\n") | ||
self.assertEqual(msg.get_payload(decode=True), | ||
"pöstal\n".encode('utf-8')) | ||
|
||
|
||
headertest_headers = ( | ||
('From: [email protected]', ('From', '[email protected]')), | ||
|
2 changes: 2 additions & 0 deletions
2
Misc/NEWS.d/next/Library/2024-04-17-18-00-30.gh-issue-80361.RstWg-.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Fix TypeError in :func:`email.Message.get_payload` when the charset is :rfc:`2231` | ||
encoded. |