gh-102988: Detect email address parsing errors and return empty tuple to indicate the parsing error (old API)#108250
gh-102988: Detect email address parsing errors and return empty tuple to indicate the parsing error (old API)#108250tdwyer wants to merge 3 commits into
Conversation
… tuple to indicate the parsing error (old API)
|
Note, I just have the regex looking for both Double Quotes and Single Quotes but I think only Double-Quotes are allowed to specify a Real Name part. Let me know if Single Quotes can NOT be used to wrap the Real Name e.g. I'll remove that from the regex if so Additionally, I'm also stripping out escaped commas before counting e.g. |
Sorry, something went wrong.
|
Any updates on that? |
Sorry, something went wrong.
|
After some investigation, I confirmed that I was being too carful before. Only commas in double-quotes should be accounted for not commas in single-quotes nor commas with prefixed with a backslash A comma in single-quotes and a comma prefixed by a backslash trigger the bug. However, a comma in double-quotes is parsed correctly. This is how all of those cases behave in: Python 2.7.17 Additionally, somehow the fix for CVE-2019-16056 regarding Python 2.7.17 So, this PR fixes both CVE-2019-16056 and CVE-2023-27043 |
Sorry, something went wrong.
|
What is necessary here to move this PR forward? |
Sorry, something went wrong.
|
My colleague Lumir Balhar @frenzymadness ran an impact check on this PR 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. I created a copy of this PR to add a strict parameter: PR #111116. |
Sorry, something went wrong.
|
Closing this in favor of Victor's updated version. |
Sorry, something went wrong.
This PR is designed to detect parsing errors and return an empty tuple to indicate the parsing error. Additionally, this PR updates the test_email.py to check for these bugs, as well as, adds some other wacky Address Headers that are in the examples of RFC 2822 and makes sure they are being parsed correctly.
I realize that this PR dose not actually track down the bug and fix it. It simply detects the error has happened and returns a parsing error. However, Lib/email/utils.py is a much simpler file than Lib/email/_parseaddr.py, so it is much easier to review this change. Additionally, there are actually multiple bugs which are causing erroneous output. Tracing the code flow for each and fixing them would be prone to error considering all of the wacky stuff that RFC 2822 allows for in Address headers. Finally, this change is actually rather simple.
📚 Documentation preview 📚: https://cpython-previews--108250.org.readthedocs.build/