mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
fixup! Stop incorrectly RFC 2047 encoding non-ASCII email addresses
- Incorporate PR feedback - Tailor blurbs to individual issues
This commit is contained in:
parent
61ac0d75f0
commit
43eaea1fb8
4 changed files with 18 additions and 13 deletions
|
@ -2846,8 +2846,8 @@ def _refold_parse_tree(parse_tree, *, policy):
|
|||
want_encoding = False
|
||||
else:
|
||||
raise errors.InvalidMailboxError(
|
||||
"Non-ASCII address requires policy with utf8=True:"
|
||||
" '{}'".format(part)
|
||||
f"Non-ASCII mailbox '{part}' is invalid"
|
||||
" under current policy setting (utf8=False)"
|
||||
)
|
||||
|
||||
if want_encoding and not wrap_as_ew_blocked:
|
||||
|
|
|
@ -306,7 +306,7 @@ class TestGeneratorBase:
|
|||
msg['To'] = address
|
||||
addr_spec = msg['To'].addresses[0].addr_spec
|
||||
expected_error = (
|
||||
fr"(?i)(?=.*non-ascii)(?=.*utf8.*True)(?=.*{re.escape(addr_spec)})"
|
||||
fr"(?i)(?=.*non-ascii)(?=.*{re.escape(addr_spec)})(?=.*policy.*utf8)"
|
||||
)
|
||||
with self.assertRaisesRegex(
|
||||
email.errors.InvalidMailboxError, expected_error
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
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`.
|
||||
The :mod:`email` module no longer incorrectly uses :rfc:`2047` encoding for
|
||||
a mailbox with non-ASCII characters in its domain. Under a policy with
|
||||
:attr:`~email.policy.EmailPolicy.utf8` set ``False``, attempting to serialize
|
||||
such a message will now raise an :exc:`~email.errors.InvalidMailboxError`.
|
||||
Either apply an appropriate IDNA encoding to convert the domain to ASCII before
|
||||
serialization, or use :data:`email.policy.SMTPUTF8` (or another policy with
|
||||
``utf8=True``) to correctly pass through the internationalized domain name
|
||||
as Unicode characters.
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
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`.
|
||||
The :mod:`email` module no longer incorrectly uses :rfc:`2047` encoding for
|
||||
a mailbox with non-ASCII characters in its local-part. Under a policy with
|
||||
:attr:`~email.policy.EmailPolicy.utf8` set ``False``, attempting to serialize
|
||||
such a message will now raise an :exc:`~email.errors.InvalidMailboxError`.
|
||||
There is no valid 7-bit encoding for an internationalized local-part. Use
|
||||
:data:`email.policy.SMTPUTF8` (or another policy with ``utf8=True``) to
|
||||
correctly pass through the local-part as Unicode characters.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue