[Python-bugs-list] [ python-Bugs-740795 ] email package won't parse correct boundary

SourceForge.net noreply@sourceforge.net
Tue, 20 May 2003 20:51:06 -0700


Bugs item #740795, was opened at 2003-05-21 09:02
Message generated for change (Comment added) made by anthonybaxter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=740795&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Piers Lauder (pierslauder)
Assigned to: Nobody/Anonymous (nobody)
Summary: email package won't parse correct boundary

Initial Comment:
the email package appears not to parse a correctly
formatted multi-part message.

I'll upload the example message, and here is the problem:
: helen ; python2.3
Python 2.3b1 (#1, Apr 26 2003, 19:55:12) 
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-110)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import email
>>> fd=open('/tmp/m1')
>>> msg=email.message_from_file(fd)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python2.3/email/__init__.py",
line 63, in message_from_file
    return Parser(_class, strict=strict).parse(fp)
  File "/usr/local/lib/python2.3/email/Parser.py", line
64, in parse
    self._parsebody(root, fp, firstbodyline)
  File "/usr/local/lib/python2.3/email/Parser.py", line
239, in _parsebody
    msgobj = self.parsestr(part)
  File "/usr/local/lib/python2.3/email/Parser.py", line
75, in parsestr
    return self.parse(StringIO(text),
headersonly=headersonly)
  File "/usr/local/lib/python2.3/email/Parser.py", line
64, in parse
    self._parsebody(root, fp, firstbodyline)
  File "/usr/local/lib/python2.3/email/Parser.py", line
245, in _parsebody
    raise Errors.BoundaryError(
email.Errors.BoundaryError: multipart message with no
defined boundary
>>>

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

>Comment By: Anthony Baxter (anthonybaxter)
Date: 2003-05-21 13:51

Message:
Logged In: YES 
user_id=29957

The inner multipart/mixed doesn't have a boundary parameter
to it's Content-Type header:

> --------------Boundary-00=_75B725CQE5HAM16NTSM1
> Content-Type: Multipart/Mixed
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> 
> Return-Path: <Postmaster@staff.cs.su.oz.au>
> Received: from staff.cs.usyd.edu.au (staff.cs.usyd.edu.au
[129.78.8.1])

>From section 5.1.1 of RFC2046:
   The Content-Type field for multipart entities requires
one parameter,
   "boundary". The boundary delimiter line is then defined
as a line
   consisting entirely of two hyphen characters ("-",
decimal value 45)
   followed by the boundary parameter value from the
Content-Type header
   field, optional linear whitespace, and a terminating CRLF.


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

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