]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
_parsebody(): Do not create subparts unless the container has a main type of
authorBarry Warsaw <barry@python.org>
Thu, 13 May 2004 23:12:33 +0000 (23:12 +0000)
committerBarry Warsaw <barry@python.org>
Thu, 13 May 2004 23:12:33 +0000 (23:12 +0000)
'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).

Lib/email/Parser.py

index 09fac4552f9379f8a32d57dd74329527c0478037..61f724ffd7089f036429620c5a9191d74bf5b925 100644 (file)
@@ -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