This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: email message parser doesn't handle \r\n correctly
Type: Stage:
Components: None Versions:
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: barry Nosy List: anadelonbrin, barry, sjoerd
Priority: normal Keywords:

Created on 2004-08-03 08:32 by sjoerd, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg21921 - (view) Author: Sjoerd Mullender (sjoerd) * (Python committer) Date: 2004-08-03 08:32
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
>>> msg = email.Parser.Parser().parsestr(m)
>>> msg.get('header')
>>> msg.get('next-header')
'more text'

This bug showed itself in my SpamBayes setup using 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'.
msg21922 - (view) Author: Tony Meyer (anadelonbrin) Date: 2004-08-05 01:28
Logged In: YES 

A patch to fix this is in:

[ 1003693 ] Fix for 1002475 (Feedparser not handling \r\n

I'll try to write a test for it, too, and also attach that.
msg21923 - (view) Author: Sjoerd Mullender (sjoerd) * (Python committer) Date: 2004-08-06 06:40
Logged In: YES 

The patch seems to work well.  +1 for checking it in.
msg21924 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2004-08-07 15:58
Logged In: YES 

Patch looks good to me.  Accepted and checked in. 1.59 1.9
Date User Action Args
2022-04-11 14:56:06adminsetgithub: 40679
2004-08-03 08:32:50sjoerdcreate