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

Guido van Rossum report at bugs.python.org
Tue Aug 11 00:58:34 CEST 2009


New submission from Guido van Rossum <guido at python.org>:

I am using an edge case of multipart/mixed and find that the
multipart/mix parser in the email package is broken.  See attached
example.  Similar code using cgi.FieldStorage (!) works fine.

The problem happens through the following combination of factors:

1. Content-Length given
2. Content-Transfer-Encoding: 8bit
3. Last two bytes of the part body are '\r\n'

In this case, the final '\n' is removed from the part body, leaving it a
byte short.  Note that interior occurrences of '\r\n' work fine, as does
any other binary data -- it's only a trailing '\r\n' that breaks.

Note that technically perhaps the use of 8bit is invalid; but the same
problem happens when using binary instead.

The problem can be reproduced in Python 3.x using nearly the same demo
by change the cStringIO import to "import io".

----------
components: Library (Lib)
files: barry.py
messages: 91466
nosy: gvanrossum
severity: normal
status: open
title: email.parser clips trailing \n of multipart/mixed part if part ends in \r\n
type: behavior
versions: Python 2.6, Python 2.7, Python 3.0, Python 3.1, Python 3.2
Added file: http://bugs.python.org/file14689/barry.py

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


More information about the New-bugs-announce mailing list