Message353624
The following will cause a KeyError on email.message.get()
import email
import email.policy
text = "Subject: =?us-ascii?X?somevalue?="
eml = email.message_from_string(text, policy=email.policy.default)
eml.get('Subject')
This is caused by the fact that the code in _encoded_words.py assumes the content-transfer-encoding of an encoded-word is always 'q' or 'b' (after lowercasing): https://github.com/python/cpython/blob/aca8c406ada3bb547765b262bed3ac0cc6be8dd3/Lib/email/_encoded_words.py#L178
I realise it's probably a silly edge case and I haven't (yet) encountered something like this in the wild, but it does seem contrary to the spirit of the email library to raise an exception like this that can propagate all the way to email.message.get(). |
|
Date |
User |
Action |
Args |
2019-09-30 20:57:33 | aft90 | set | recipients:
+ aft90, barry, r.david.murray |
2019-09-30 20:57:33 | aft90 | set | messageid: <1569877053.41.0.568400002445.issue38332@roundup.psfhosted.org> |
2019-09-30 20:57:33 | aft90 | link | issue38332 messages |
2019-09-30 20:57:33 | aft90 | create | |
|