[New-bugs-announce] [issue39757] EmailMessage wrong encoding for international domain

Julien Castiaux report at bugs.python.org
Wed Feb 26 04:36:15 EST 2020


New submission from Julien Castiaux <julien.castiaux at gmail.com>:

Affected 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 at 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 at 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.

----------
components: email
messages: 362687
nosy: Julien Castiaux, barry, r.david.murray
priority: normal
severity: normal
status: open
title: EmailMessage wrong encoding for international domain
type: behavior
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39757>
_______________________________________


More information about the New-bugs-announce mailing list