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 — email.utils.getaddresses() rejects email addresses with "," in name · Issue #106669 · python/cpython

email.utils.getaddresses() rejects email addresses with "," in name #106669

New issue
Copy link
New issue
Copy link
Closed
Closed
email.utils.getaddresses() rejects email addresses with "," in name#106669
Copy link
Assignees
gpshead
Labels
3.12only security fixesonly security fixes3.13only security fixesonly security fixesrelease-blockertopic-emailtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@felixxm
felixxm
opened on Jul 12, 2023
Issue body actions

Bug report

email.utils.getaddresses() returns ('', '') for email addresses with , in a real name, e.g.

>>> from email.utils import getaddresses
>>> getaddresses(('"Sürname, Firstname" <[email protected]>',))
[('', '')]

Regression in 18dfbd0.

Your environment

  • CPython versions tested on: 3.12.0b4
  • Operating system and architecture: x86_64 GNU/Linux

Linked PRs

  • gh-106669: Revert "gh-102988: Detect email address parsing errors ... (#105127)" #106733
  • [3.12] gh-106669: Revert "gh-102988: Detect email address parsing errors ... (GH-105127)" (GH-106733) #106941
Reacted by Paolo Melchiorre and Gregory P. Smith

Activity

  1. felixxm
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jul 12, 2023
  2. felixxm commented on Jul 12, 2023

    @felixxm
    felixxm
    on Jul 12, 2023
    ContributorAuthor
    More actions

    A regression test:

    diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py
    index 5238944d6b..30ade53a9a 100644
    --- a/Lib/test/test_email/test_email.py
    +++ b/Lib/test/test_email/test_email.py
    @@ -3319,6 +3319,22 @@ def test_getaddresses(self):
                [('Al Person', '[email protected]'),
                 ('Bud Person', '[email protected]')])
     
    +    def test_getaddresses_comma_in_name(self):
    +        self.assertEqual(
    +            utils.getaddresses(
    +                [
    +                    '"Bud, Person" <[email protected]>',
    +                    '[email protected] (Al Person)',
    +                    '"Mariusz Felisiak" <[email protected]>',
    +                ]
    +            ),
    +            [
    +                ('Bud Person', '[email protected]'),
    +                ('Al Person', '[email protected]'),
    +                ('Mariusz Felisiak', '[email protected]'),
    +            ],
    +        )
    +
         def test_getaddresses_parsing_errors(self):
             """Test for parsing errors from CVE-2023-27043"""
             eq = self.assertEqual
    Reacted by Gregory P. Smith
  3. AlexWaygood
    added
    topic-email
    3.12only security fixesonly security fixes
    3.13only security fixesonly security fixes
    on Jul 12, 2023
  4. AlexWaygood
    assigned
    gpshead
    on Jul 12, 2023
  5. gpshead
    added
    release-blocker
    on Jul 12, 2023
  6. ezio-melotti
    added this to Release and Deferred blockers 🚫on Jul 12, 2023
  7. github-project-automation
    moved this to Todo in Release and Deferred blockers 🚫on Jul 12, 2023
  8. rouilj commented on Jul 13, 2023

    @rouilj
    rouilj
    on Jul 13, 2023
    More actions

    Thanks for finding this. It blew up the regression testing for the Roundup Issue Tracker during my release yesterday. Specifically for:

    email.utils.getaddresses(['"Bork, Chef" [email protected]'])
    [('', '')]

    Any idea if there will be a beta-5 to fix this? If not I could use some ideas on how to
    handle/decorate the three tests that are failing when run on 3.12.

    Thanks.

    Reacted by Gregory P. Smith
  9. gpshead
    added a commit that references this issue on Jul 14, 2023

    pythongh-106669: Revert "pythongh-102988: Detect email address parsin…

    362793e
  10. gpshead commented on Jul 14, 2023

    @gpshead
    gpshead
    on Jul 14, 2023
    Member
    More actions

    If you add a test skip decorator, I'd do it specifically for 3.12beta4. Something like this:

    @unittest.skipIf(sys.version_info == (3, 12, 0, 'beta', 4), "https://github.com/python/cpython/issues/106669")
    def test_oops(self): ...

    It does not look like there is an easy acceptable workaround for the bug as the source of the problem appears to be the comma counting logic added near the end of email.utils.getaddresses().

    It's up to @Yhg1s to decide if this warrants a beta5 or not. I've prepared a rollback of the change that caused it.

    Reacted by John P. Rouillard
  11. gpshead
    added 3 commits that reference this issue on Jul 21, 2023

    gh-106669: Revert "gh-102988: Detect email address parsing errors ... (…

    a31dea1

    [3.12] pythongh-106669: Revert "pythongh-102988: Detect email address…

    4288c62

    [3.12] gh-106669: Revert "gh-102988: Detect email address parsing err…

    656f624
  12. michel-slm commented on Jul 26, 2023

    @michel-slm
    michel-slm
    on Jul 26, 2023
    More actions

    This also breaks b4 very similarly to Django; mentioning here for reference

    https://bugzilla.redhat.com/show_bug.cgi?id=2226159

        def test_header_wrapping(sampledir, hval, verify, tr):
            hname = 'To' if '@' in hval else "X-Header"
            wrapped = b4.LoreMessage.wrap_header((hname, hval), transform=tr)
    >       assert wrapped.decode() == f'{hname}: {verify}'
    E       assert 'To: ' == 'To: foo@[email protected]>'
    E         + To: 
    E         - To: [email protected], Foo Bar <[email protected]>, 
    E         -  =?utf-8?q?F=C3=B4o_Baz?= <[email protected]>, "Quux, Foo" <[email protected]>
    tests/test___init__.py:171: AssertionError
    
  13. gpshead commented on Jul 26, 2023

    @gpshead
    gpshead
    on Jul 26, 2023
    Member
    More actions

    The rollbacks were merged and will appear in 3.12.0rc1.

  14. gpshead
    closed this as completedon Jul 26, 2023
  15. github-project-automation
    moved this from Todo to Done in Release and Deferred blockers 🚫on Jul 26, 2023
  16. bmwiedemann
    added a commit that references this issue on Jul 27, 2023

    Update python39 to version 3.9.17 / rev 47 via SR 1100886

    fb07387
  17. bmwiedemann
    added 5 commits that reference this issue on Aug 4, 2023

    Update python38 to version 3.8.17 / rev 39 via SR 1102235

    61b9ace

    Update python312 to version 3.12.0b4 / rev 5 via SR 1102238

    0bfafc7

    Update python310 to version 3.10.12 / rev 35 via SR 1102193

    55c5f8a

    Update python39 to version 3.9.17 / rev 49 via SR 1102236

    ef4b44f

    Update python311 to version 3.11.4 / rev 21 via SR 1102237

    c4336af
  18. bmwiedemann
    added a commit that references this issue on Aug 15, 2023

    Update python to version 2.7.18 / rev 186 via SR 1103620

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

Metadata

Metadata

Assignees

  • @gpshead
    gpshead

Labels

3.12only security fixesonly security fixes3.13only security fixesonly security fixesrelease-blockertopic-emailtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

  • Release and Deferred blockers 🚫
    Status
    Done
    Show more project fields

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.