New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-38332: catch KeyError from unknown cte in encoded-word #16503
Conversation
Hi @aft90, thanks for the PR. Please open a BPO (https://bugs.python.org) to https://bugs.python.org |
I have: https://bugs.python.org/issue38332. BPO seems to be unresponsive at the moment, so I'll update it when it's back up. |
I think the changes look good, although, it would be good to have a NEWS item too. This seems It is good to have a changelog for bugfixes in case we need to refer to it later. |
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). CLA MissingOur records indicate the following people have not signed the CLA: For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
…er-encoding in encoded-word ; add tests
Hmm, not sure why it wasn't merged automatically since it seems to have the right labels. Merging manually! |
GH-16596 is a backport of this pull request to the 3.8 branch. |
GH-16597 is a backport of this pull request to the 3.7 branch. |
…-16503) KeyError should cause a failure in parsing the encoded word and should be caught and raised as a _InvalidEWError instead.
Given an encoded-word with an invalid content-transfer-encoding (something other than
b
orq
, for instance:=?utf-8?X?somevalue?=
),_encoded_words.decode()
throws aKeyError
which propagates all the way down toemail.message.get()
.Fix is to explicitly catch the
KeyError
inget_encoded_word
and raiseInvalidEwError
which then causesget_unstructured
to return the value unchanged.If accepted, this should be backported to 3.5 through to 3.8
https://bugs.python.org/issue38332
Automerge-Triggered-By: @maxking