Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-83938, gh-122476: Stop incorrectly RFC 2047 encoding non-ASCII email addresses#122540
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
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
0abca3e
faa4006
f8f5eef
99914e3
819c0bc
bd6845d
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2837,6 +2837,17 @@ def _refold_parse_tree(parse_tree, *, policy): | ||
_fold_mime_parameters(part, lines, maxlen, encoding) | ||
continue | ||
if want_encoding and part.token_type == 'addr-spec': | ||
# RFC2047 forbids encoded-word in any part of an addr-spec. | ||
if charset == 'unknown-8bit': | ||
# Non-ASCII addr-spec came from parsed message; leave unchanged. | ||
want_encoding = False | ||
else: | ||
raise errors.InvalidMailboxError( | ||
"Non-ASCII address requires policy with utf8=True:" | ||
" '{}'".format(part) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Would f"Non-ASCII mailbox {str(part)!r} is invalid under current policy setting (utf8=False)" be clearer do you think? | ||
) | ||
if want_encoding and not wrap_as_ew_blocked: | ||
if not part.as_ew_allowed: | ||
want_encoding = False | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
The :mod:`email` module no longer incorrectly encodes non-ASCII characters | ||
in email addresses using :rfc:`2047` encoding. Under a policy with ``utf8=True`` | ||
this means the addresses will be correctly passed through. Under a policy with | ||
``utf8=False``, attempting to serialize a message with non-ASCII email addresses | ||
will now result in an :exc:`~email.errors.InvalidMailboxError`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
The :mod:`email` module no longer incorrectly encodes non-ASCII characters | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Duplicate news item. | ||
in email addresses using :rfc:`2047` encoding. Under a policy with ``utf8=True`` | ||
this means the addresses will be correctly passed through. Under a policy with | ||
``utf8=False``, attempting to serialize a message with non-ASCII email addresses | ||
will now result in an :exc:`~email.errors.InvalidMailboxError`. |
Uh oh!
There was an error while loading.Please reload this page.