[issue6681] email.parser clips trailing \n of multipart/mixed part if part ends in \r\n

R. David Murray report at bugs.python.org
Sat Aug 15 00:12:06 CEST 2009


R. David Murray <rdmurray at bitdance.com> added the comment:

The only way I can think of to fix this that won't fail in the case
where the body ends with just '\r' (rather than '\r\n' the way the test
body does) is to have feedparser keep track of what the overall line
endings for the stream being parsed are.  ie: to basicly outlaw
mixed-line-ending input (except insofar as such alternate line endings
are encoded in a non-text multipart).  That seems like something that
should only be considered in the context of email 6.0 rather than in a
bug fix.

cgi doesn't use a RE, by the way, it just looks at the last two
chars...and is subject to the same bug if a part ends with '\r' in input
with '\n' line terminators.

I've attached a patch that turns Guido's test into a test case, and
fixes his edge case.  I did not touch the other places where the eol RE
is used, since in those cases there should not be binary data preceeding
the line ending characters.

----------
keywords: +patch
priority:  -> normal
stage:  -> patch review
Added file: http://bugs.python.org/file14729/issue6681.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6681>
_______________________________________


More information about the Python-bugs-list mailing list