| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
@gpshead @serhiy-storchaka @bitdancer @warsaw: Would you mind to review this security fix? See issue gh-102988 for the context. This PR is a copy of PR #108250 but I added strict=True parameter, so it's possible to get the old behavior. I added tests on both modes, strict=True and strict=False. |
Sorry, something went wrong.
My colleague Lumir Balhar @frenzymadness ran an impact check of PR #108250 on Fedora: in short, there is no impact, the test suite of all Python packages (in Fedora) pass with the change. While there were some build errors, they were unrelated to the email issue. For details, see https://copr.fedorainfracloud.org/coprs/lbalhar/email-CVE/builds/ COPR which as more than 4300 builds. Now with an additional strict parameter, if there is any impacted project, at least there is a way to "opt out". |
Sorry, something went wrong.
|
@tdwyer: Would you mind to review my change, to see if I preserved your work correctly? (code and tests) |
Sorry, something went wrong.
|
I think that we should backport the change to all branches accepting security fixes. Problem: the change refer to version numbers, which as .. versionchanged:: 3.13. I suppose that if the change is backported, we should compute the next version of each branch, so backport manually. |
Sorry, something went wrong.
|
@ambv @SethMichaelLarson: Would you mind to review this PR? |
Sorry, something went wrong.
|
Why is this a separate PR from #108250? |
Sorry, something went wrong.
| parameter to these two functions: use ``strict=False`` to get the old | ||
| behavior, accept malformed inputs. | ||
| (Contributed by Thomas Dwyer for :gh:`102988` to ameliorate CVE-2023-27043 | ||
| (Contributed by Thomas Dwyer for :gh:`102988` to improve the CVE-2023-27043 |
There was a problem hiding this comment.
TIL a new word.
Sorry, something went wrong.
|
|
||
| specialsre = re.compile(r'[][\\()<>@,:;".]') | ||
| escapesre = re.compile(r'[\\"]') | ||
| realname_comma_re = re.compile(r'"[^"]*,[^"]*"') |
There was a problem hiding this comment.
| realname_comma_re = re.compile(r'"[^"]*,[^"]*"') | |
| realname_comma_re = re.compile(r'"[^",]*+,[^"]*+"') |
It is faster. But I am not sure that the use of such regex is correct.
Sorry, something went wrong.
| def _pre_parse_validation(email_header_fields): | ||
| accepted_values = [] | ||
| for v in email_header_fields: | ||
| s = v.replace('\\(', '').replace('\\)', '') |
There was a problem hiding this comment.
But what if that backslash was already escaped with a backslash? For example \\) or \\\\).
Sorry, something went wrong.
I'm not the author of the other PR. I copied the other PR and added strict parameter. |
Sorry, something went wrong.
|
I'm not the author of this PR and I was able to make commits to it. |
Sorry, something went wrong.
I don't feel comfortable to make significant change of a PR without asking the author. I prefer to create a separated PR and ask for review. |
Sorry, something went wrong.
|
Is this behavior a bug or a feature? I don't know how ; is supposed to behave. Details$ python
Python 3.11.6 (main, Oct 3 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from email.utils import getaddresses
>>> from pprint import pprint
>>> pprint(getaddresses('<bob@example.org>; <alice@example.org>'))
[('', ''),
('', 'b'),
('', 'o'),
('', 'b'),
('', ''),
('', 'e'),
('', 'x'),
('', 'a'),
('', 'm'),
('', 'p'),
('', 'l'),
('', 'e'),
('', '.'),
('', 'o'),
('', 'r'),
('', 'g'),
('', ''),
('', ''),
('', ''),
('', ''),
('', 'a'),
('', 'l'),
('', 'i'),
('', 'c'),
('', 'e'),
('', ''),
('', 'e'),
('', 'x'),
('', 'a'),
('', 'm'),
('', 'p'),
('', 'l'),
('', 'e'),
('', '.'),
('', 'o'),
('', 'r'),
('', 'g'),
('', '')]
|
Sorry, something went wrong.
Oh. getaddresses() expects a sequence, not a string :-) |
Sorry, something went wrong.
|
Except of parsedate_tz() function, Lib/email/_parseaddr.py file didn't evolve much it was added in 2002 by commit 030ddf7. The file was created from Lib/rfc822.py which was added in 1992 (commit 01ca336). The latest major change was done in... 1997 with commit be7c45e
The latest minor change was done in 2019 to fix CVE-2019-16056: commit 8cb65d1 of issue #78336. |
Sorry, something went wrong.
Oh, realname_comma_re replaces "Jane Doe" <jane@example.net>, "John Doe" <john@example.net> with "Jane Doe <john@example.net> which is invalid... |
Sorry, something went wrong.
|
Email addresses have multiple standards:
|
Sorry, something went wrong.
|
Is it time to backport the change to Python 3.8-3.12? So far, nobody reported any regression in Python 3.13. |
Sorry, something went wrong.
Of course, I am eager for reviews and comments. So far, the only issue I have heard about was confusion about str/unicode objects in Python 2.7 (https://bugzilla.suse.com/1222537), which I think may be your problem as well. Also, I left some comments on that commit. |
Sorry, something went wrong.
According to this comment, not yet: #102988 (comment) |
Sorry, something went wrong.
…n email.parseaddr() (python#111116) Detect email address parsing errors and return empty tuple to indicate the parsing error (old API). Add an optional 'strict' parameter to getaddresses() and parseaddr() functions. Patch by Thomas Dwyer. Co-Authored-By: Thomas Dwyer <github@tomd.tel>
…n email.parseaddr() (python#111116) Detect email address parsing errors and return empty tuple to indicate the parsing error (old API). Add an optional 'strict' parameter to getaddresses() and parseaddr() functions. Patch by Thomas Dwyer. Co-Authored-By: Thomas Dwyer <github@tomd.tel>
….parseaddr() (python#111116) Detect email address parsing errors and return empty tuple to indicate the parsing error (old API). Add an optional 'strict' parameter to getaddresses() and parseaddr() functions. Patch by Thomas Dwyer. Co-Authored-By: Thomas Dwyer <github@tomd.tel>
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10. |
Sorry, something went wrong.
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Sorry, something went wrong.
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11. |
Sorry, something went wrong.
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.9. |
Sorry, something went wrong.
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8. |
Sorry, something went wrong.
|
Sorry, @vstinner, I could not cleanly backport this to 3.12 due to a conflict. cherry_picker 4a153a1d3b18803a684cd1bcc2cdf3ede3dbae19 3.12 |
Sorry, something went wrong.
|
Sorry, @vstinner, I could not cleanly backport this to 3.10 due to a conflict. cherry_picker 4a153a1d3b18803a684cd1bcc2cdf3ede3dbae19 3.10 |
Sorry, something went wrong.
|
Sorry, @vstinner, I could not cleanly backport this to 3.11 due to a conflict. cherry_picker 4a153a1d3b18803a684cd1bcc2cdf3ede3dbae19 3.11 |
Sorry, something went wrong.
|
Sorry, @vstinner, I could not cleanly backport this to 3.9 due to a conflict. cherry_picker 4a153a1d3b18803a684cd1bcc2cdf3ede3dbae19 3.9 |
Sorry, something went wrong.
|
Sorry, @vstinner, I could not cleanly backport this to 3.8 due to a conflict. cherry_picker 4a153a1d3b18803a684cd1bcc2cdf3ede3dbae19 3.8 |
Sorry, something went wrong.
|
GH-123766 is a backport of this pull request to the 3.12 branch. |
Sorry, something went wrong.
|
GH-123767 is a backport of this pull request to the 3.11 branch. |
Sorry, something went wrong.
|
GH-123768 is a backport of this pull request to the 3.10 branch. |
Sorry, something went wrong.
|
GH-123769 is a backport of this pull request to the 3.9 branch. |
Sorry, something went wrong.
|
GH-123770 is a backport of this pull request to the 3.8 branch. |
Sorry, something went wrong.
|
supports_strict_parsing is not mentioned in the email.utils docs. |
Sorry, something went wrong.
|
please open a new issue if there's a lingering docs problem. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Detect email address parsing errors and return empty tuple to indicate the parsing error (old API). Add an optional 'strict' parameter to getaddresses() and parseaddr() functions. Patch by Thomas Dwyer.
📚 Documentation preview 📚: https://cpython-previews--111116.org.readthedocs.build/