diff options
author | R David Murray <rdmurray@bitdance.com> | 2014-02-08 18:12:00 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2014-02-08 18:12:00 (GMT) |
commit | 0400d33928e6b463db164836da670700f03edc5d (patch) | |
tree | 70c96ca143468dfe5e7fcfc827fc32bf37d4ff4b /Lib/email | |
parent | 905c8c3d8dfe081d91e399aa5fd93d1659655264 (diff) | |
download | cpython-0400d33928e6b463db164836da670700f03edc5d.zip cpython-0400d33928e6b463db164836da670700f03edc5d.tar.gz cpython-0400d33928e6b463db164836da670700f03edc5d.tar.bz2 |
#16983: Apply postel's law to encoded words inside quoted strings.
This applies only to the new parser. The old parser decodes encoded words
inside quoted strings already, although it gets the whitespace wrong
when it does so.
This version of the patch only handles the most common case (a single encoded
word surrounded by quotes), but I haven't seen any other variations of this in
the wild yet, so its good enough for now.
Diffstat (limited to 'Lib/email')
-rw-r--r-- | Lib/email/_header_value_parser.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py index 291437c..0369e01 100644 --- a/Lib/email/_header_value_parser.py +++ b/Lib/email/_header_value_parser.py @@ -1559,6 +1559,13 @@ def get_bare_quoted_string(value): while value and value[0] != '"': if value[0] in WSP: token, value = get_fws(value) + elif value[:2] == '=?': + try: + token, value = get_encoded_word(value) + bare_quoted_string.defects.append(errors.InvalidHeaderDefect( + "encoded word inside quoted string")) + except errors.HeaderParseError: + token, value = get_qcontent(value) else: token, value = get_qcontent(value) bare_quoted_string.append(token) |