other possible issue with the feedparser (email.message_from_*)

xavier delannoy <[email protected]> Fri, 12 Aug 2011 13:33:24 +0200
Newsgroups gmane.comp.python.mime.devel
Message-ID <[email protected]>
--------------090703080907060809010702
Content-Type: text/plain; charset="ISO-8859-1"; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

Before opening a bug report at bugs.python.org, I wish to have your
feedback on this:

When a "\r\n" is missing between the headers and the body, the
feedparser silently fix the issue. The ouput buffer is modified (the
\r\n is added, and nothing is appended to the defects list.

In my opinion, as the output buffer is modified, this is a bug.

In the attachment you'll find files.tgz which contains :
   - orig.eml : original email
   - after.eml: output of email.message_from_string
   - test.py: short test script

original email:
{{{
Received: from 127.0.0.1 ([192.168.254.1]) by IMP with bizsmtp
   id 4Z3J1h00102awG001Z3J01; Wed, 06 Jul 2011 11:03:18 +0200
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00800000
Message-ID: <[email protected]>
Date: Wed, 29 Jun 2011 14:28:04 +0800
From: test <[email protected]>
To: [email protected]
Subject: a test subject
Here's a wrong email body... \r\n are missing
}}}

email parsed by the feedparser:
{{{
Received: from 127.0.0.1 ([192.168.254.1]) by IMP with bizsmtp
   id 4Z3J1h00102awG001Z3J01; Wed, 06 Jul 2011 11:03:18 +0200
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00800000
Message-ID: <[email protected]>
Date: Wed, 29 Jun 2011 14:28:04 +0800
From: test <[email protected]>
To: [email protected]
Subject: a test subject

Here's a wrong email body... \r\n are missing
}}}

Xavier

--------------090703080907060809010702
Content-Type: application/x-compressed-tar; name="files.tgz"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="files.tgz"

H4sIAEkPRU4AA+2WbWvbMBDH89rg73BzXzRhjSI5tpN6zdhY262FwFgHG1uHkWM51fATltws
/fST46SkhKyFkpYO/fJC3Ol0+gvpzqGxZCViadLaHVjhOU49koGL18cFrue2CPFsYmOn7/Rb
mNiu47UA71DTLZWQtARo/aHXnJXR1rj75l8oX9iE8WsW+RCXeQrEHiCsfgTaP8mhjYg3ROoy
EPnVgXAOZ+PPMOPyCkJ+I1JZGMAjcH70z8mVulNs09lHNSobkzfwjUUHgD04rxKwMSFAiI/7
PhnCa2xjbHzvjvMbniS0eyGprIQP9cPYcNu1f7h4KMaYCUGnrHt27MORc4Lff3BPlTjcxy62
3wmaFglDkzx9axxTyfxGgn2oJGRLCY5vD33sKAkqpXGqzuyDZELCUX3+Oym+5moqX3MZF1X4
m02kD7RZIxrbMD6xku0L5Z6VeTYFllKeQJhHc4QQXJaXGdCSQcqF4NnUNJ770tfISz7dcfnf
X/+DZf2Tgde3cV3/DiG6/p+Cx9W/+ZgGYG7pAJv+tRZgPrwHmA9rAuY/u4C52QbMbX3AfIF9
oNaPivlO96jvbeC62+vftde+/15d/32s6/9J2HvVq0TZC3nWY9k1FHN5lWfGHkzySD1RHyoZ
d4eGwdMiL2XzoFdGxOM44aGxaByLGTQ+G5+Mq0TygqqAZdwdp0oVQxBkNGVBAKMRWEGglmZB
YPkGKOICRpAXLGtbqLf6OlkHsF+G+51FRMjiXFXRSIWiktEo4RkT7c5yNZokuWDKXNipmKrA
RlzaNI6g1hsIWarztS0L/c551m5ydpokmzro6l+yEmLNrNu9ZiWXrK02QVSsUp7SRKwyrct5
7pvWaDQajUaj0Wg0Go1Go9FoNBqNRqPRaDT/O38BMR/UwwAoAAA=
--------------090703080907060809010702
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline