[ python-Bugs-1002475 ] email message parser doesn't handle \r\n correctly

SourceForge.net noreply at sourceforge.net
Fri Aug 6 08:40:03 CEST 2004


Bugs item #1002475, was opened at 2004-08-03 10:32
Message generated for change (Comment added) made by sjoerd
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1002475&group_id=5470

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Sjoerd Mullender (sjoerd)
Assigned to: Nobody/Anonymous (nobody)
Summary: email message parser doesn't handle \r\n correctly

Initial Comment:
Header lines that end in \r\n only get the \n stripped,
not the \r (unless it's the last header which does get
the \r stripped):

>>> import email.Parser
>>> m = 'Header: text\r\nNext-Header: more
text\r\n\r\nBody\r\n\r\n'
>>> msg = email.Parser.Parser().parsestr(m)
>>> msg.get('header')
'text\r'
>>> msg.get('next-header')
'more text'
>>>

This bug showed itself in my SpamBayes setup using
sb_imapfilter.py where base64-encoded text/html
messages were not decoded in Message.get_payload
because the call to get('content-transfer-encoding')
returned the string 'base64\r' instead of 'base64'.

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

>Comment By: Sjoerd Mullender (sjoerd)
Date: 2004-08-06 08:40

Message:
Logged In: YES 
user_id=43607

The patch seems to work well.  +1 for checking it in.

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

Comment By: Tony Meyer (anadelonbrin)
Date: 2004-08-05 03:28

Message:
Logged In: YES 
user_id=552329

A patch to fix this is in:

[ 1003693 ] Fix for 1002475 (Feedparser not handling \r\n
correctly)
http://sourceforge.net/tracker/index.php?func=detail&aid=1003693&group_id=5470&atid=305470

I'll try to write a test for it, too, and also attach that.

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

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


More information about the Python-bugs-list mailing list