Possible bug in Email and Multifile Modules ?

Steven D. Arnold stevena at neosynapse.net
Sat Sep 7 16:29:15 EDT 2002

I'm picking up on a very old thread because I am only now encountering
issues related to it.

> On Mon, Feb 04, 2002 at 01:01:43AM -0800, Sheila King wrote:
>> >>> msg = email.message_from_file(open('virus.txt'))
>> Traceback (most recent call last):
>>   File "<interactive input>", line 1, in ?
>>   File "E:\PYTHON\PYTHON22\lib\email\__init__.py", line 35, in
>> message_from_file
>>     return _Parser(_class).parse(fp)
>>   File "E:\PYTHON\PYTHON22\lib\email\Parser.py", line 40, in parse
>>     self._parsebody(root, fp)
>>   File "E:\PYTHON\PYTHON22\lib\email\Parser.py", line 116, in _parsebody
>>     raise Errors.BoundaryError(
>> BoundaryError: Couldn't find terminating boundary:
>> ====_ABC1234567890DEF_====
>> =============(end interpreter session)================
>> Now, it turns out that this message is not well formed. Instead of the
>> correct closing boundary at the end of the message, it has a boundary which
>> indicates that another part should follow.
>> >  No parts were removed, it's 100% intact. And you're right, it's not
>> >  well-formed, but that's the whole idea behind it. It tricks Outlook
>> >  into executing the attachment.
>> > But not being well-formed shouldn't break anything...
>    GIF viewer should not display EXE-files. PDF viewer should not print
> broken PDFs. And email scanner should not scan files that are not emails.
> Just drop it on the flor and forget.

I disagree.  Excellent GIF viewers should do their best to display
even broken GIF files.  Same goes for PDF, etc.  Likewise, an
excellent Python email library will do its best to handle and
correctly process broken emails.  I would say the above represents an
unfortunate prima donna attitude which ultimately reduces the utility
of Python's libraries.

In my application, I'm trying to process a message based on its
header, but I can't even get the header information, because instead
of trying to intelligently handle a broken MIME message, an exception
is raised.  Since I have no alternative but to find a way to
automatically handle even broken messages, I either have to patch the
email module to do what I want or reproduce much of the same logic in
my own module.  I'd like to patch the email module and submit the
patch for inclusion in the standard library.  What is the process for
this?  Any other suggestions or comments would be appreciated as well.

Steven D. Arnold                                    Neosynapse
stevena at neosynapse.net                        Managing Partner
AIM: abraxan                       MSN: neosynapse at hotmail.com

More information about the Python-list mailing list