mirror of
https://github.com/python/cpython.git
synced 2025-08-31 22:18:28 +00:00
\r\n only get the \n stripped, not the \r (unless it's the last header which does get the \r stripped). Patch by Tony Meyer. test_whitespace_continuation_last_header(), test_strip_line_feed_and_carriage_return_in_headers(): New tests. _parse_headers(): Be sure to strip \r\n from the right side of header lines.
This commit is contained in:
parent
14d535c3d4
commit
8896bf56a2
2 changed files with 33 additions and 3 deletions
|
@ -415,7 +415,8 @@ class FeedParser:
|
|||
continue
|
||||
if lastheader:
|
||||
# XXX reconsider the joining of folded lines
|
||||
self._cur[lastheader] = EMPTYSTRING.join(lastvalue)[:-1]
|
||||
lhdr = EMPTYSTRING.join(lastvalue)[:-1].rstrip('\r\n')
|
||||
self._cur[lastheader] = lhdr
|
||||
lastheader, lastvalue = '', []
|
||||
# Check for envelope header, i.e. unix-from
|
||||
if line.startswith('From '):
|
||||
|
@ -449,4 +450,4 @@ class FeedParser:
|
|||
# Done with all the lines, so handle the last header.
|
||||
if lastheader:
|
||||
# XXX reconsider the joining of folded lines
|
||||
self._cur[lastheader] = EMPTYSTRING.join(lastvalue).rstrip()
|
||||
self._cur[lastheader] = EMPTYSTRING.join(lastvalue).rstrip('\r\n')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue