[Python-Dev] [Python-checkins] cpython (merge 3.2 -> default): Merge #15232: correctly mangle From lines in MIME preamble and epilogue (original) (raw)
Meador Inge meadori at gmail.com
Mon Jul 23 07:34:02 CEST 2012
- Previous message: [Python-Dev] 2to3 porting HOWTO: setup.py question
- Next message: [Python-Dev] [Python-checkins] cpython (merge 3.2 -> default): Merge #15232: correctly mangle From lines in MIME preamble and epilogue
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, Jul 22, 2012 at 8:55 PM, r.david.murray <python-checkins at python.org> wrote:
http://hg.python.org/cpython/rev/80b81658455b changeset: 78246:80b81658455b parent: 78244:c43d73277756 parent: 78245:b97f65f2298d user: R David Murray <rdmurray at bitdance.com> date: Sun Jul 22 21:53:54 2012 -0400 summary: Merge #15232: correctly mangle From lines in MIME preamble and epilogue
files: Lib/email/generator.py | 12 ++++++++- Lib/test/testemail/testemail.py | 22 +++++++++++++++++++ Misc/NEWS | 3 ++ 3 files changed, 35 insertions(+), 2 deletions(-)
I'm not quite sure what happened, but something seems to have gone wrong with this merge. After doing the following while on the "default" branch:
$ hg merge 3.2
I see:
$ hg st M Lib/email/generator.py M Lib/test/test_email/test_email.py M Misc/NEWS
and a bunch of conflicts in 'Misc/NEWS'.
diff --git a/Lib/email/generator.py b/Lib/email/generator.py --- a/Lib/email/generator.py +++ b/Lib/email/generator.py @@ -252,7 +252,11 @@ msg.setboundary(boundary) # If there's a preamble, write it out, with a trailing CRLF if msg.preamble is not None: - self.write(msg.preamble + self.NL) + if self.manglefrom: + preamble = fcre.sub('>From ', msg.preamble) + else: + preamble = msg.preamble + self.write(preamble + self.NL) # dash-boundary transport-padding CRLF self.write('--' + boundary + self.NL) # body-part @@ -270,7 +274,11 @@ self.write(self.NL + '--' + boundary + '--') if msg.epilogue is not None: self.write(self.NL) - self.write(msg.epilogue) + if self.manglefrom: + epilogue = fcre.sub('>From ', msg.epilogue) + else: + epilogue = msg.epilogue + self.write(epilogue) def handlemultipartsigned(self, msg): # The contents of signed parts has to stay unmodified in order to keep diff --git a/Lib/test/testemail/testemail.py b/Lib/test/testemail/testemail.py --- a/Lib/test/testemail/testemail.py +++ b/Lib/test/testemail/testemail.py @@ -1283,6 +1283,28 @@ Blah blah blah """) + def testmanglefrominpreambleandepilog(self): + s = StringIO() + g = Generator(s, manglefrom=True) _+ msg = email.messagefromstring(textwrap.dedent("""_ + From: foo at bar.com + Mime-Version: 1.0 + Content-Type: multipart/mixed; boundary=XXX + + From somewhere unknown + + --XXX + Content-Type: text/plain + + foo + + --XXX-- + + From somewhere unknowable + """)) + g.flatten(msg) + self.assertEqual(len([1 for x in s.getvalue().split('\n') + if x.startswith('>From ')]), 2)
# Test the basic MIMEAudio class diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -52,6 +52,9 @@ Library ------- +- Issue #15232: when manglefrom is True, email.Generator now correctly mangles + lines that start with 'From' that occur in a MIME preamble or epilogue. + - Issue #15094: Incorrectly placed #endif in tkinter.c. Patch by Serhiy Storchaka. -- Repository URL: http://hg.python.org/cpython
Python-checkins mailing list Python-checkins at python.org http://mail.python.org/mailman/listinfo/python-checkins
--
Meador
- Previous message: [Python-Dev] 2to3 porting HOWTO: setup.py question
- Next message: [Python-Dev] [Python-checkins] cpython (merge 3.2 -> default): Merge #15232: correctly mangle From lines in MIME preamble and epilogue
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]