[Python-bugs-list] [ python-Bugs-417176 ] MultiFile.read() includes CRLF boundary

noreply@sourceforge.net noreply@sourceforge.net
Tue, 18 Sep 2001 08:09:38 -0700


Bugs item #417176, was opened at 2001-04-18 15:22
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=417176&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: Fixed
Priority: 5
Submitted By: Martijn Pieters (mjpieters)
Assigned to: Guido van Rossum (gvanrossum)
Summary: MultiFile.read() includes CRLF boundary

Initial Comment:
multifile.MultiFile.readlines()and .read() will return 
a body of a multipart message including the line 
delimiter that is to be regarded part of the boundary.

In a partial multipart message like:

--BoundaryHere
Content-Type: text/plain

1
2
3
4
--BoundaryHere

the message within the delimiters does not include the 
final line delimiter (CRLF or LF or whatnot) after the 
line reading '4'; it is considered part of the 
boundary. MultiFile however, returns it as part of the 
body.

See RFC2046 section 5.1.1. In the usual text 
formatting of the RFC, you'll find the definition and 
explanation in the first two paragraphs of page 19.


----------------------------------------------------------------------

>Comment By: Martijn Pieters (mjpieters)
Date: 2001-09-18 08:09

Message:
Logged In: YES 
user_id=116747

Your patch looks sound, apart from the fact it'll only
remove a LF. The Spec says the CRLF is part of the boundary,
and, to account for broken implementations, it should
probably remove and of 'CRLF', 'LF', or 'CR' at the end.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-09-18 07:34

Message:
Logged In: YES 
user_id=6380

I've checked in the patch now. Still waiting for Martijn's
feedback before I close the report.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-09-13 12:59

Message:
Logged In: YES 
user_id=6380

Martijn, here's a fix. Can you test this?

The fix works (how else) by reading ahead one line and
stripping the final newline if the next line is empty.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-09-05 10:54

Message:
Logged In: YES 
user_id=6380

I wrote that code and I'm probably culpable.  It's also
always bothered me.

Unassigning it from Barry (it has nothing to do with Barry).

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=417176&group_id=5470