Commits

Barry Warsaw committed 16386cb

_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).

  • Participants
  • Parent commits d3ca6bd
  • Branches 2.3

Comments (0)

Files changed (1)

Lib/email/Parser.py

-# 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.
 """
         # 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