diff options
author | Barry Warsaw <barry@python.org> | 2004-08-07 15:57:52 +0000 |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2004-08-07 15:57:52 +0000 |
commit | 8896bf56a2955c2bb5d380a7e6cfed044f10b869 (patch) | |
tree | 9c78ef341e3020142a56239d850e420b84ff22e3 /Lib/email/FeedParser.py | |
parent | 14d535c3d45010919cb1fc2e3830f24041ae02c5 (diff) | |
download | cpython-git-8896bf56a2955c2bb5d380a7e6cfed044f10b869.tar.gz |
Resolution of SF bug #1002475 and patch #1003693; Header lines that end in
\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.
Diffstat (limited to 'Lib/email/FeedParser.py')
-rw-r--r-- | Lib/email/FeedParser.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/email/FeedParser.py b/Lib/email/FeedParser.py index af0e177d56..dc3027dbda 100644 --- a/Lib/email/FeedParser.py +++ b/Lib/email/FeedParser.py @@ -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') |