Issue815563
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2003-10-01 02:32 by customdesigned, last changed 2022-04-10 16:11 by admin. This issue is now closed.
Files | ||||
---|---|---|---|---|
File name | Uploaded | Description | Edit | |
fail | customdesigned, 2003-10-01 02:32 | example of a failing message |
Messages (5) | |||
---|---|---|---|
msg54024 - (view) | Author: Stuart D. Gathman (customdesigned) | Date: 2003-10-01 02:32 | |
The following proglet gets an except with the attached message: -----te.py-------- import email import sys msg = email.message_from_file(sys.stdin) sys.stdout.write(msg.as_string()) ------------------ python2 te.py <failingmsg Traceback (most recent call last): File "te.py", line 4, in ? msg = email.message_from_file(sys.stdin) File "/usr/lib/python2.2/email/__init__.py", line 63, in message_from_file return Parser(_class, strict=strict).parse(fp) File "/usr/lib/python2.2/email/Parser.py", line 64, in parse self._parsebody(root, fp, firstbodyline) File "/usr/lib/python2.2/email/Parser.py", line 239, in _parsebody msgobj = self.parsestr(part) File "/usr/lib/python2.2/email/Parser.py", line 75, in parsestr return self.parse(StringIO(text), headersonly=headersonly) File "/usr/lib/python2.2/email/Parser.py", line 64, in parse self._parsebody(root, fp, firstbodyline) File "/usr/lib/python2.2/email/Parser.py", line 264, in _parsebody msg = self.parse(fp) File "/usr/lib/python2.2/email/Parser.py", line 64, in parse self._parsebody(root, fp, firstbodyline) File "/usr/lib/python2.2/email/Parser.py", line 205, in _parsebody raise Errors.BoundaryError( email.Errors.BoundaryError: No terminating boundary and no trailing empty line ------------------- The message/rfc822 attachment really is missing the boundary. However, that is why it is being returned as an attachment in the first place! Is it illegal for message/rfc822 attachments to have invalid MIME construction? I suggest that a message attachment that fails MIME boundary decoding, should become a plain rfc822 object, or perhaps a text object. I don't know. Anyway, I get tons of messages with this property that have to be processed by my Python milter. |
|||
msg54025 - (view) | Author: Barry A. Warsaw (barry) * | Date: 2003-11-21 20:36 | |
Logged In: YES user_id=12800 I'm moving this to a feature request for Python 2.4. There's little that we can do about this in Python 2.3 since the lax parser is only so good at guessing the intent of ill-formed messages. email 2.x can't do what you suggest because that would be a new feature and can't be introduced into Python 2.3. The email-sig is chartered with developing an improved parser for Python 2.4 that might be able to handle this. In the meantime, you could probably derive your own Parser class that might be able to worm around this problem in an application specific way. |
|||
msg54026 - (view) | Author: Stuart D. Gathman (customdesigned) | Date: 2003-11-21 20:52 | |
Logged In: YES user_id=142072 Your disposition makes sense. Since all messages with invalid MIME boundaries are either invalid themselves, or bounces or forwards of invalid messages, my work around is to issue an SMTP reject: if exc_type == email.Errors.BoundaryError: self.setreply('554','5.7.7', 'Boundary error in your message, are you a spammer?') For 2.4, I recommend that rfc822 attachments be parsed independently of the enclosing message. If the attachment is invalid, turn it into a plain rfc822 message object or a string. Although the rfc822 module is deprecated, I find it very useful to represent mail that may or may not correctly follow MIME standards. Examples include forwarded spam (using the new innoculation RFC), and generic mailbox processing. I suggest retaining rfc822 as a 'featureless' message with only headers and body. |
|||
msg54027 - (view) | Author: Barry A. Warsaw (barry) * | Date: 2003-11-21 21:00 | |
Logged In: YES user_id=12800 Note that if you're looking for something that just parses messages into headers and bodies, you might look at the HeaderParser class. You'd have to write a bit of code to get an outer parser that falls back to a HeaderParser on invalid unparseable inner messages. |
|||
msg54028 - (view) | Author: Collin Winter (collinwinter) * | Date: 2007-03-30 14:50 | |
I don't see any exception as of Python 2.5. Closing as "fixed". |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:11:30 | admin | set | github: 39341 |
2003-10-01 02:32:02 | customdesigned | create |