Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
0d255966
Commit
0d255966
authored
Feb 08, 2014
by
R David Murray
Browse files
Options
Browse Files
Download
Plain Diff
Merge: #16983: Apply postel's law to encoded words inside quoted strings.
parents
24391845
e716933d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
0 deletions
+29
-0
Lib/email/_header_value_parser.py
Lib/email/_header_value_parser.py
+7
-0
Lib/test/test_email/test__header_value_parser.py
Lib/test/test_email/test__header_value_parser.py
+9
-0
Lib/test/test_email/test_headerregistry.py
Lib/test/test_email/test_headerregistry.py
+10
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/email/_header_value_parser.py
View file @
0d255966
...
...
@@ -1556,6 +1556,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
)
...
...
Lib/test/test_email/test__header_value_parser.py
View file @
0d255966
...
...
@@ -540,6 +540,15 @@ class TestParser(TestParserMixin, TestEmailBase):
self._test_get_x(parser.get_bare_quoted_string,
'""', '""', '', [], '')
# Issue 16983: apply postel's law to some bad encoding.
def test_encoded_word_inside_quotes(self):
self._test_get_x(parser.get_bare_quoted_string,
'"
=
?
utf
-
8
?
Q
?
not_really_valid
?
=
"',
'"
not
really
valid
"',
'not really valid',
[errors.InvalidHeaderDefect],
'')
# get_comment
def test_get_comment_only(self):
...
...
Lib/test/test_email/test_headerregistry.py
View file @
0d255966
...
...
@@ -1155,6 +1155,16 @@ class TestAddressHeader(TestHeaderBase):
'example.com'
,
None
),
'rfc2047_atom_in_quoted_string_is_decoded'
:
(
'"=?utf-8?q?=C3=89ric?=" <foo@example.com>'
,
[
errors
.
InvalidHeaderDefect
],
'Éric <foo@example.com>'
,
'Éric'
,
'foo@example.com'
,
'foo'
,
'example.com'
,
None
),
}
# XXX: Need many more examples, and in particular some with names in
...
...
Misc/NEWS
View file @
0d255966
...
...
@@ -27,6 +27,9 @@ Core and Builtins
Library
-------
- Issue #16983: the new email header parsing code will now decode encoded words
that are (incorrectly) surrounded by quotes, and register a defect.
- Issue #19772: email.generator no longer mutates the message object when
doing a down-transform from 8bit to 7bit CTEs.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment