Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

email generator can give bad output #39506

Closed
crunch mannequin opened this issue Nov 5, 2003 · 2 comments
Closed

email generator can give bad output #39506

crunch mannequin opened this issue Nov 5, 2003 · 2 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@crunch
Copy link
Mannequin

crunch mannequin commented Nov 5, 2003

BPO 836293
Nosy @warsaw

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/warsaw'
closed_at = <Date 2003-11-21.16:38:16.000>
created_at = <Date 2003-11-05.06:26:55.000>
labels = ['invalid', 'library']
title = 'email generator can give bad output'
updated_at = <Date 2003-11-21.16:38:16.000>
user = 'https://bugs.python.org/crunch'

bugs.python.org fields:

activity = <Date 2003-11-21.16:38:16.000>
actor = 'barry'
assignee = 'barry'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2003-11-05.06:26:55.000>
creator = 'crunch'
dependencies = []
files = []
hgrepos = []
issue_num = 836293
keywords = []
message_count = 2.0
messages = ['18903', '18904']
nosy_count = 2.0
nosy_names = ['barry', 'crunch']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue836293'
versions = ['Python 2.3']

@crunch
Copy link
Mannequin Author

crunch mannequin commented Nov 5, 2003

#!/usr/bin/env python
#Feedback to crunch@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@microsoft.com>
To: <poorsap@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."

@crunch crunch mannequin closed this as completed Nov 5, 2003
@crunch crunch mannequin added the invalid label Nov 5, 2003
@crunch crunch mannequin assigned warsaw Nov 5, 2003
@crunch crunch mannequin added the stdlib Python modules in the Lib dir label Nov 5, 2003
@crunch crunch mannequin closed this as completed Nov 5, 2003
@crunch crunch mannequin added the invalid label Nov 5, 2003
@crunch crunch mannequin assigned warsaw Nov 5, 2003
@crunch crunch mannequin added the stdlib Python modules in the Lib dir label Nov 5, 2003
@warsaw
Copy link
Member

warsaw commented Nov 21, 2003

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.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

1 participant