[Python-bugs-list] [ python-Bugs-794458 ] email bug with message/rfc822

SourceForge.net noreply at sourceforge.net
Mon Aug 25 20:48:45 EDT 2003


Bugs item #794458, was opened at 2003-08-24 23:17
Message generated for change (Comment added) made by customdesigned
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=794458&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Stuart D. Gathman (customdesigned)
Assigned to: Barry A. Warsaw (bwarsaw)
Summary: email bug with message/rfc822

Initial Comment:
Attached is a test message that the email module can't
even read in andd write back out.  It drops a whole
section of headers for the message/rfc822 part.  The
old email modules handle this message correctly.

Let me clarify the problem with a short test:

------te.py--------
import email
import sys

msg = email.message_from_file(sys.stdin)
sys.stdout.write(msg.as_string())
-------------------
$ python2 te.py <test8 >test8.out
$ diff test8 test8.out
.... lots of differences that shouldn't be there ....


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

>Comment By: Stuart D. Gathman (customdesigned)
Date: 2003-08-25 22:48

Message:
Logged In: YES 
user_id=142072

Here is a fix for this bug.  The problem is that the message
attachment is not being decoded before parsing.

*** Parser.py   Mon Aug 25 22:43:34 2003
--- /usr/lib/python2.2/email/Parser.py  Tue Nov 12 16:50:20 2002
***************
*** 249,262 ****
          elif container.get_main_type() == 'message':
              # Create a container for the payload, but
watch out for there not
              # being any headers left
-             container.set_payload(fp.read())
-           fp = StringIO(container.get_payload(decode=True))
              try:
                  msg = self.parse(fp)
              except Errors.HeaderParseError:
                  msg = self._class()
                  self._parsebody(msg, fp)
!             container.set_payload([msg])
          else:
              container.set_payload(fp.read())
  
--- 249,260 ----
          elif container.get_main_type() == 'message':
              # Create a container for the payload, but
watch out for there not
              # being any headers left
              try:
                  msg = self.parse(fp)
              except Errors.HeaderParseError:
                  msg = self._class()
                  self._parsebody(msg, fp)
!             container.attach(msg)
          else:
              container.set_payload(fp.read())
  


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

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



More information about the Python-bugs-list mailing list