Commit 0ecaf068 authored by Barry Warsaw's avatar Barry Warsaw

_parsebody(): When adding subparts to a multipart container, make sure

that the first subpart added makes the payload a list object.
Otherwise, a multipart/* with only one subpart will not have the
proper structure.
parent 55b39b75
# Copyright (C) 2001 Python Software Foundation # Copyright (C) 2001,2002 Python Software Foundation
# Author: barry@zope.com (Barry Warsaw) # Author: barry@zope.com (Barry Warsaw)
"""A parser of RFC 2822 and MIME email messages. """A parser of RFC 2822 and MIME email messages.
""" """
from cStringIO import StringIO from cStringIO import StringIO
from types import ListType
# Intrapackage imports # Intrapackage imports
import Errors import Errors
...@@ -133,6 +134,10 @@ class Parser: ...@@ -133,6 +134,10 @@ class Parser:
msgobj = self.parsestr(part) msgobj = self.parsestr(part)
container.preamble = preamble container.preamble = preamble
container.epilogue = epilogue container.epilogue = epilogue
# Ensure that the container's payload is a list
if not isinstance(container.get_payload(), ListType):
container.set_payload([msgobj])
else:
container.add_payload(msgobj) container.add_payload(msgobj)
elif container.get_type() == 'message/delivery-status': elif container.get_type() == 'message/delivery-status':
# This special kind of type contains blocks of headers separated # This special kind of type contains blocks of headers separated
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment