-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-38332: catch KeyError from unknown cte in encoded-word #16503
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
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(copy here my bpo comments)
I am not a email expert, but according to RFC 1342 the enconding can be either "B" or "Q". So, I think is reasonable that when a not correct enconding is set, should be raise an exception
I think that we can improve the message raising a more specific Exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I test it and work successfully. IMO the NEW is not necessary. Good catch @aft90
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @aft90 for working on this.
It looks good to me!
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. |
…-16503) KeyError should cause a failure in parsing the encoded word and should be caught and raised as a _InvalidEWError instead. (cherry picked from commit 65dcc8a) Co-authored-by: Andrei Troie <[email protected]>
GH-16597 is a backport of this pull request to the 3.7 branch. |
KeyError should cause a failure in parsing the encoded word and should be caught and raised as a _InvalidEWError instead. (cherry picked from commit 65dcc8a) Co-authored-by: Andrei Troie <[email protected]>
KeyError should cause a failure in parsing the encoded word and should be caught and raised as a _InvalidEWError instead. (cherry picked from commit 65dcc8a) Co-authored-by: Andrei Troie <[email protected]>
…-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