Repository navigation
EmailMessage bad encoding for international domain #83938
Description
Activity
Julien00859 commented
on Feb 26, 2020 Julien00859mannequinMannequinAuthorMore actionsAffected python version: 3.5 and above (did test them all except 3.9)
Steps to reproduce:
from mail.message import EmailMessage from mail.policy import SMTP msg = EmailMessage(policy=SMTP) msg['To'] = 'Joe <joe@examplé.com>' # notice the é in the domain print(msg.as_string())
It prints
To: "Joe <joe@=?utf-8?q?exampl=C3=A9?=.com>"But it should be
To: "Joe <joe@xn--exampl-gva.com>"While b64/qp can be used to encode most non-ascii headers, the domain part of an email address is an exception. According to IDNA2008 (rfc5890 , rfc5891), non-ascii domain should be encoded using the punycode algorithm and the ACE prefix.
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Feb 26, 2020 Julien00859 commented
on Feb 27, 2020 Julien00859mannequinMannequinAuthorMore actionsDuplicate of https://bugs.python.org/issue39757
Julien00859 commented
on Feb 27, 2020 Julien00859mannequinMannequinAuthorMore actionsWoops wrong copie/paste, here is the correct link: https://bugs.python.org/issue11783
This is not actually a duplicate of 11783. Rereading (parts of) that issue, we decided we currently have no good way to do automatic conversion between unicode and internationalized domains, so the user of the library has to do it themselves. This means that the bug *here* is that the new email API is *wrongly* encoding the non-ascii in the domain by using an encoded word. I'm surprised at that; I thought I'd guarded against it.
What should be happening here is that an error should be raised when that header is set (or possibly when it is accessed/serialized, but when set would be better I think) saying that there is non-ascii in the domain part.
- changed the title
[-]EmailMessage wrong encoding for international domain[/-][+]EmailMessage bad encoding for international domain[/+]on Feb 28, 2020 Reproduced on 3.11.
- added3.9 (EOL)end of lifeend of life3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes
on Dec 13, 2021 - addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
on Nov 23, 2023
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs