Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-94606: Fix error when message with Unicode surrogate not surrogateescaped string#94641

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
serhiy-storchaka merged 9 commits intopython:mainfromsidney:issue-94606-get_payload
Dec 11, 2023

Conversation

@sidney
Copy link
Contributor

@sidneysidney commentedJul 7, 2022
edited by bedevere-bot
Loading

Fix for issue#94606 email.message.get_payload raises UnicodeEncodeError when the message body contains a Unicode surrogate character but is not a valid string that can be decoded using surrogateescape

Added a more strict test for string being surrogateescape decoded that is only used on strings that pass the fast heuristic test, which should be rare.

arhadthedev and ekamioka reacted with thumbs up emoji
@sidneysidney requested a review froma team as acode ownerJuly 7, 2022 05:21
@ghost
Copy link

ghost commentedJul 7, 2022
edited by ghost
Loading

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-bot
Copy link

Most changes to Pythonrequire a NEWS entry.

Please add it using theblurb_it web app or theblurb command-line tool.

@serhiy-storchakaserhiy-storchaka self-requested a reviewJuly 7, 2022 08:31
erlend-aaslandand others added4 commitsJuly 7, 2022 20:49
…timization for blocks that have a line number (pythonGH-94592)Inlining of code that corresponds to source code lines, can make it hard to distinguish later between code which is only reachable from except handlers, and that which is reachable in normal control flow. This caused problems with the debugger's jump feature.This PR turns off the inlining optimisation for code which has line numbers. We still inline things like the implicit "return None".
@sidney
Copy link
ContributorAuthor

Somehow I ended up with four commits by erland-assland for sqlite3 showing up in this PR. All I thought I did was add a commit to my branch for a change to the unit tests. Did I do something wrong in git, and is this PR now messed when it comes to merging?

@arhadthedev
Copy link
Member

Whatever it was, all commits will be squashed while merging anyway. So there is nothing worth fixing.

Comment on lines 293 to 294
ifutils._has_decoded_with_surrogateescape(payload):
bpayload=payload.encode('ascii','surrogateescape')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

payload.encode('ascii', 'surrogateescape') is calculated twice. First in_has_decoded_with_surrogateescape(), the, if it successes, the result is dropped and it is encoded again here. It is possible to optimize this, but it requires larger change.

@serhiy-storchakaserhiy-storchaka added needs backport to 3.11only security fixes needs backport to 3.12only security fixes labelsDec 11, 2023
@serhiy-storchakaserhiy-storchaka merged commit27a5fd8 intopython:mainDec 11, 2023
@miss-islington-app
Copy link

Thanks@sidney for the PR, and@serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestDec 11, 2023
…rogateescaped string (pythonGH-94641)(cherry picked from commit27a5fd8)Co-authored-by: Sidney Markowitz <sidney@sidney.com>Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-app
Copy link

GH-112971 is a backport of this pull request to the3.12 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.12only security fixes labelDec 11, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestDec 11, 2023
…rogateescaped string (pythonGH-94641)(cherry picked from commit27a5fd8)Co-authored-by: Sidney Markowitz <sidney@sidney.com>Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-app
Copy link

GH-112972 is a backport of this pull request to the3.11 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.11only security fixes labelDec 11, 2023
serhiy-storchaka added a commit that referenced this pull requestDec 11, 2023
…rrogateescaped string (GH-94641) (GH-112972)(cherry picked from commit27a5fd8)Co-authored-by: Sidney Markowitz <sidney@sidney.com>Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this pull requestDec 11, 2023
…rrogateescaped string (GH-94641) (GH-112971)(cherry picked from commit27a5fd8)Co-authored-by: Sidney Markowitz <sidney@sidney.com>Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
aisk pushed a commit to aisk/cpython that referenced this pull requestFeb 11, 2024
…rogateescaped string (pythonGH-94641)Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Glyphack pushed a commit to Glyphack/cpython that referenced this pull requestSep 2, 2024
…rogateescaped string (pythonGH-94641)Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@serhiy-storchakaserhiy-storchakaserhiy-storchaka approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

email.message get_payload throws UnicodeEncodeError with some surrogate Unicode characters

6 participants

@sidney@bedevere-bot@arhadthedev@serhiy-storchaka@erlend-aasland@iritkatriel

[8]ページ先頭

©2009-2025 Movatter.jp