diff options
author | Barry Warsaw <barry@python.org> | 2004-05-11 20:19:09 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2004-05-11 20:19:09 (GMT) |
commit | d38f4488651f3a36b9bc8d44001b9ed76576e549 (patch) | |
tree | 61dfc916b88b2444ace68926f96b75633bb66112 /Lib/email/FeedParser.py | |
parent | c312b07d77d4aee2cce69bafa0393428a6fc2314 (diff) | |
download | cpython-d38f4488651f3a36b9bc8d44001b9ed76576e549.zip cpython-d38f4488651f3a36b9bc8d44001b9ed76576e549.tar.gz cpython-d38f4488651f3a36b9bc8d44001b9ed76576e549.tar.bz2 |
_parsegen(): Move the message/rfc822 clause to after the
message/delivery-status clause, and genericize it to handle all (other)
message/* content types. This lets us correctly parse 2 more of Anthony's
MIME torture tests (specifically, the message/external-body examples).
Diffstat (limited to 'Lib/email/FeedParser.py')
-rw-r--r-- | Lib/email/FeedParser.py | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/Lib/email/FeedParser.py b/Lib/email/FeedParser.py index c980f9a..d28170e 100644 --- a/Lib/email/FeedParser.py +++ b/Lib/email/FeedParser.py @@ -211,21 +211,12 @@ class FeedParser: lines.append(line) self._cur.set_payload(EMPTYSTRING.join(lines)) return - # So now the input is sitting at the first body line. If the message - # claims to be a message/rfc822 type, then what follows is another RFC - # 2822 message. - if self._cur.get_content_type() == 'message/rfc822': - for retval in self._parsegen(): - if retval is NeedMoreData: - yield NeedMoreData - continue - break - self._pop_message() - return if self._cur.get_content_type() == 'message/delivery-status': # message/delivery-status contains blocks of headers separated by # a blank line. We'll represent each header block as a separate - # nested message object. A blank line separates the subparts. + # nested message object, but the processing is a bit different + # than standard message/* types because there is no body for the + # nested messages. A blank line separates the subparts. while True: self._input.push_eof_matcher(NLCRE.match) for retval in self._parsegen(): @@ -249,6 +240,16 @@ class FeedParser: # Not at EOF so this is a line we're going to need. self._input.unreadline(line) return + if self._cur.get_content_maintype() == 'message': + # The message claims to be a message/* type, then what follows is + # another RFC 2822 message. + for retval in self._parsegen(): + if retval is NeedMoreData: + yield NeedMoreData + continue + break + self._pop_message() + return if self._cur.get_content_maintype() == 'multipart': boundary = self._cur.get_boundary() if boundary is None: |