[ python-Bugs-836293 ] email generator can give bad output
SourceForge.net
noreply at sourceforge.net
Fri Nov 21 11:38:16 EST 2003
Bugs item #836293, was opened at 2003-11-05 01:26
Message generated for change (Comment added) made by bwarsaw
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=836293&group_id=5470
Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: John Draper (crunch)
Assigned to: Barry A. Warsaw (bwarsaw)
Summary: email generator can give bad output
Initial Comment:
#!/usr/bin/env python
#Feedback to crunch at shopip.com
#Python 2.3.2 under OpenBSD 3.4 i386
import email
print r"""
Example of Python email generator bug.
If a MIME message is missing the terminating line, the
generator creates one for it -only it forgets to add the
\n\n to it. This causes the following message to be
concatenated to the first.
"""
#s1 is MIME missing terminating line;
#s2 is a proper MIME message.
s1="""Received: by spameater (127.0.0.1)...
From: "Victor Virus" <security at microsoft.com>
To: <poorsap at host.net>
Subject: Unterminated MIME to corrupt your mbox!
MIME-Version: 1.0
Content-Type: multipart/mixed;boundary="xxxx"
--xxxx
Content-Type: text/plain;
This is an unterminated MIME, like many viruses
generate. I don't care about rights of viruses,
but I do care if improper handling of MIME causes
following messages to be lost.
--xxxx
"""
s2=s1+"""--xxxx--\n\n""" #Create properly terminator
msg1=email.message_from_string(s1)
msg2=email.message_from_string(s2)
print str(msg1)+str(msg2)
print "p.s. Notice how the first message runs into the"
print " second message."
print " By adding the missing '--', this won't happen."
----------------------------------------------------------------------
>Comment By: Barry A. Warsaw (bwarsaw)
Date: 2003-11-21 11:38
Message:
Logged In: YES
user_id=12800
This really isn't a bug in the email package, since it's
doing what is expected of it. The MIME RFC actually
attaches newlines to the front of any boundary and does not
specify any required newlines after the terminator. If you
look carefully at msg1 and msg2, you'll find that for the
latter, all those extra newlines get assigned to the
.epilogue which, like the .preamble is text outside the MIME
encapsulation.
If you want to use the output of the Generator to create a
Unix style mbox format file, you'll need to either add the
extra newlines to the epilogue yourself, or checked the
str() of msg1 to see if it contains the number of newlines
your external (read: mbox) format requires.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=836293&group_id=5470
More information about the Python-bugs-list
mailing list