[Patches] [ python-Patches-1555570 ] email parser incorrectly breaks headers with a CRLF at 8192

SourceForge.net noreply at sourceforge.net
Wed Dec 6 18:54:11 CET 2006


Patches item #1555570, was opened at 2006-09-09 18:41
Message generated for change (Comment added) made by jdunck
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1555570&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Tony Meyer (anadelonbrin)
Assigned to: Barry A. Warsaw (bwarsaw)
Summary: email parser incorrectly breaks headers with a CRLF at 8192

Initial Comment:
If a message has a CRLF as part of a header that starts
at 8191, the parser will incorrectly consider the
headers to finish at 8191 and the body to start at
8193, which leaves headers in the body of the message.

This problem occurs because the parser reads 8192
characters at a time.  If 8192 is a '\r' and 8193 a
'\n', then when the second block is parsed, it will
appear to be a blank line (i.e. header separator).

The simplest fix for this is to just read an extra
character if the last one read is a '\r'.  This appears
to work fine without breaking anything, although I
suppose that an alternative would be to change the
FeedParser to check whether the '\n' belonged with the
previous data.

A patch and test are attached, against SVN of 10/Sept/06.

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

Comment By: Jeremy Dunck (jdunck)
Date: 2006-12-06 11:54

Message:
Logged In: YES 
user_id=516425
Originator: NO

We're hitting this bug as well.
It affects Django, which handles media upload over HTTP by parsing
multipart with email.message_from_string.

pegasusnews.com, FWIW.

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

Comment By: Graham King (graham_king)
Date: 2006-12-06 05:30

Message:
Logged In: YES 
user_id=1237146
Originator: NO

 I had exactly the same problem parsing a POST encoded as
'multipart/form-data' with lots of parts. The patch provided fixes it. I'm
on ActivePython 2.4.3 so I applied the patch by hand.

 +1 for integrating this patch into Python.

 Thanks,
 Graham King.


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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1555570&group_id=5470


More information about the Patches mailing list