[Python-bugs-list] [ python-Bugs-594255 ] email mishandles some multiparts

noreply@sourceforge.net noreply@sourceforge.net
Mon, 12 Aug 2002 14:13:00 -0700


Bugs item #594255, was opened at 2002-08-12 14:13
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=594255&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Tim Roberts (timroberts)
Assigned to: Nobody/Anonymous (nobody)
Summary: email mishandles some multiparts

Initial Comment:
Python 2.2 on Windows 2000; also occurs in Python 2.1.

email.Message.Message.is_multipart() returns true if 
and only if _payload is a list.  _payload becomes a list 
only if more than one subpart is added.  However, by 
RFC 1521, a multipart message is allowed to contain a 
single subpart.  (I received one today!)  In that case, 
Message.is_multipart() returns false, and Message.walk 
fails to enumerate the subpart.  There seems to be no 
way to discover that a parsable payload exists.

Suggested and tested fix is to modify the start of 
Message.add_payload from this:

        if self._payload is None:
            self._payload = payload

to this:

        if self._payload is None:
            if self.get_main_type() == 'multipart':
                self._payload = [payload]
            else:
                self._payload = payload


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=594255&group_id=5470