GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — EmailMessage bad encoding for international domain · Issue #83938 · python/cpython

EmailMessage bad encoding for international domain #83938

New issue
Copy link
New issue
Copy link
Closed
#122540
Closed
EmailMessage bad encoding for international domain#83938
#122540
Copy link
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-emailtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

Julien00859
mannequin
opened on Feb 26, 2020
Issue body actions
BPO 39757
Nosy @warsaw, @bitdancer, @Julien00859, @iritkatriel
PRs
  • bpo-39757: Use IDNA to encode domain part in email address #18667
  • 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:

    assignee = None
    closed_at = None
    created_at = <Date 2020-02-26.09:36:15.270>
    labels = ['3.11', 'type-bug', 'expert-email', '3.10', '3.9']
    title = 'EmailMessage bad encoding for international domain'
    updated_at = <Date 2021-12-13.17:50:29.456>
    user = 'https://github.com/Julien00859'

    bugs.python.org fields:

    activity = <Date 2021-12-13.17:50:29.456>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['email']
    creation = <Date 2020-02-26.09:36:15.270>
    creator = 'Julien Castiaux'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39757
    keywords = ['patch']
    message_count = 5.0
    messages = ['362687', '362801', '362802', '362906', '408472']
    nosy_count = 4.0
    nosy_names = ['barry', 'r.david.murray', 'Julien Castiaux', 'iritkatriel']
    pr_nums = ['18667']
    priority = 'normal'
    resolution = None
    stage = 'needs patch'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue39757'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    Linked PRs

    • gh-83938, gh-122476: Stop incorrectly RFC 2047 encoding non-ASCII email addresses #122540

    Activity

    1. Julien00859 commented on Feb 26, 2020

      @Julien00859
      Julien00859mannequin
      on Feb 26, 2020
      MannequinAuthor
      More actions

      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@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 <[email protected]>"
      

      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.

    2. Julien00859
      added
      topic-email
      type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
      on Feb 26, 2020
    3. Julien00859 commented on Feb 27, 2020

      @Julien00859
      Julien00859mannequin
      on Feb 27, 2020
      MannequinAuthor
      More actions

      Duplicate of https://bugs.python.org/issue39757

    4. Julien00859
      closed this as completedon Feb 27, 2020
    5. Julien00859 commented on Feb 27, 2020

      @Julien00859
      Julien00859mannequin
      on Feb 27, 2020
      MannequinAuthor
      More actions

      Woops wrong copie/paste, here is the correct link: https://bugs.python.org/issue11783

    6. bitdancer commented on Feb 28, 2020

      @bitdancer
      bitdancer
      on Feb 28, 2020
      Member
      More actions

      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.

    7. bitdancer
      reopened this on Feb 28, 2020
    8. bitdancer
      changed the title [-]EmailMessage wrong encoding for international domain[/-] [+]EmailMessage bad encoding for international domain[/+] on Feb 28, 2020
    9. iritkatriel commented on Dec 13, 2021

      @iritkatriel
      iritkatriel
      on Dec 13, 2021
      Member
      More actions

      Reproduced on 3.11.

    10. iritkatriel
      added
      3.9 (EOL)end of lifeend of life
      3.10 (EOL)end of lifeend of life
      3.11only security fixesonly security fixes
      on Dec 13, 2021
    11. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    12. iritkatriel
      added
      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
      on Nov 23, 2023
    13. bitdancer
      closed this as completedin #122540on May 1, 2026
    14. bitdancer
      added a commit that references this issue on May 1, 2026

      gh-83938, gh-122476: Stop incorrectly RFC 2047 encoding non-ASCII ema…

      d96ffc1
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-emailtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions

        You are visitor 01402503 — GeezerVison does not store the pages you look up.
        Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.