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 #106669DescriptionBug 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
Reacted by Paolo Melchiorre and Gregory P. Smith Activityfelixxm commented 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.assertEqualReacted by Gregory P. Smith rouilj commented on Jul 13, 2023 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 gpshead commented on Jul 14, 2023 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 michel-slm commented on Jul 26, 2023 gpshead commented on Jul 26, 2023 The rollbacks were merged and will appear in 3.12.0rc1.
MetadataMetadataStatusShow more project fields
DevelopmentNo branches or pull requestsIssue actions
|