[Patches] [ python-Patches-1003693 ] Fix for 1002475 (Feedparser not handling \r\n correctly)

SourceForge.net noreply at sourceforge.net
Sat Aug 7 17:58:31 CEST 2004


Patches item #1003693, was opened at 2004-08-04 21:27
Message generated for change (Settings changed) made by bwarsaw
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1003693&group_id=5470

Category: Library (Lib)
Group: Python 2.4
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Tony Meyer (anadelonbrin)
Assigned to: Barry A. Warsaw (bwarsaw)
Summary: Fix for 1002475 (Feedparser not handling \r\n correctly)

Initial Comment:
Python 2.4a1/Anon CVS of 5 Aug 2004.  WinXP SP1, not
that that matters.

This is a patch to fix bug:

[ 1002475 ] email message parser doesn't handle \r\n
correctly
http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=1002475

Basically, FeedParser does a rstrip() on the last
header value, but not any of the others.  Given that
RFC822 wants the headers to end with \r\n, it's likely
that most will, and this means that all the headers
except for the last end with \r.  This one line patch
just does the extra rstrip.

Note that you might want to implement the fix yourself
- it doesn't fit on a line, and so it's wrapped in an
ugly way - maybe you can think of something prettier :)
 This does fix the problem, though (here, at least,
using the test case outlined in the bug report).

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

Comment By: Sjoerd Mullender (sjoerd)
Date: 2004-08-06 02:39

Message:
Logged In: YES 
user_id=43607

I've only tried the patch, not the test, but it seems to
work well.

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

Comment By: Tony Meyer (anadelonbrin)
Date: 2004-08-04 22:09

Message:
Logged In: YES 
user_id=552329

Second test was in the wrong place, so moving.

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

Comment By: Tony Meyer (anadelonbrin)
Date: 2004-08-04 21:48

Message:
Logged In: YES 
user_id=552329

Also attached is a patch for test_email.py.  This adds two
new tests (which fail before the FeedParser.py patch, and
pass afterwards).

The first tests that the \r\n characters are correctly removed.
The second is a copy of an existing test to check
continuations with whitespace, but checks if it works with
the continuation as the last header.

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

Comment By: Tony Meyer (anadelonbrin)
Date: 2004-08-04 21:46

Message:
Logged In: YES 
user_id=552329

Attaching new patch, because that one breaks one of the
tests.  The rstrip() needs to be rstrip('\r\n') or it strips
other whitespace that isn't allowed there.

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

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


More information about the Patches mailing list