From: Barry Warsaw Date: Thu, 13 May 2004 23:12:33 +0000 (+0000) Subject: _parsebody(): Do not create subparts unless the container has a main type of X-Git-Tag: v2.3.4~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=36d0f15a0b6d5c058b229d740bc09973247e4036;p=thirdparty%2FPython%2Fcpython.git _parsebody(): Do not create subparts unless the container has a main type of 'multipart' and the boundary is defined. This fixes SF bug # 846938, and several recent email-sig bugs where something like a text/html message also had a boundary parameter. This would later crash the Generator, which only consulted the Content-Type to decide how to generate the message (and it would expect just a string, but find a list there instead). --- diff --git a/Lib/email/Parser.py b/Lib/email/Parser.py index 09fac4552f93..61f724ffd708 100644 --- a/Lib/email/Parser.py +++ b/Lib/email/Parser.py @@ -1,5 +1,5 @@ -# Copyright (C) 2001,2002 Python Software Foundation -# Author: barry@zope.com (Barry Warsaw) +# Copyright (C) 2001-2004 Python Software Foundation +# Author: barry@python.org (Barry Warsaw) """A parser of RFC 2822 and MIME email messages. """ @@ -145,11 +145,12 @@ class Parser: # boundary if present. boundary = container.get_boundary() isdigest = (container.get_content_type() == 'multipart/digest') - # If there's a boundary, split the payload text into its constituent - # parts and parse each separately. Otherwise, just parse the rest of - # the body as a single message. Note: any exceptions raised in the - # recursive parse need to have their line numbers coerced. - if boundary: + # If there's a boundary and the message has a main type of + # 'multipart', split the payload text into its constituent parts and + # parse each separately. Otherwise, just parse the rest of the body + # as a single message. Note: any exceptions raised in the recursive + # parse need to have their line numbers coerced. + if container.get_content_maintype() == 'multipart' and boundary: preamble = epilogue = None # Split into subparts. The first boundary we're looking for won't # always have a leading newline since we're at the start of the