summaryrefslogtreecommitdiffstats
path: root/Lib/email/FeedParser.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2004-12-05 03:45:42 (GMT)
committerBarry Warsaw <barry@python.org>2004-12-05 03:45:42 (GMT)
commit7cf9ce24409efb70efde08e350a4170dc98008a1 (patch)
tree0bb15e7e9f836e06f95db9509b18d21d1d99ec0e /Lib/email/FeedParser.py
parent6c92d76abc730ca7a77da3c7a8627192f7ac3add (diff)
downloadcpython-7cf9ce24409efb70efde08e350a4170dc98008a1.zip
cpython-7cf9ce24409efb70efde08e350a4170dc98008a1.tar.gz
cpython-7cf9ce24409efb70efde08e350a4170dc98008a1.tar.bz2
Fixes for SF #1076485, which I'll apply to the CVS head too. The problem was
caused by a self._input.readline() call that wasn't checking for the NeedsMoreData marker. msg_43.txt contains a message that illustrates the problem, when email.message_from_*() is called. That interface uses the Parser API, which splits reads into 8192 byte chunks. It so happens that for the test message, the 8192 chunk falls inside a message/delivery-status, which is where in the FeedParser the readline() call was that didn't check for NeedsMoreData. I also added an assert to unreadline() so it'll be more evident if an attempt to push back NeedsMoreData ever happens again. Bump the email package version number.
Diffstat (limited to 'Lib/email/FeedParser.py')
-rw-r--r--Lib/email/FeedParser.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/Lib/email/FeedParser.py b/Lib/email/FeedParser.py
index f514728..5aad15d 100644
--- a/Lib/email/FeedParser.py
+++ b/Lib/email/FeedParser.py
@@ -87,6 +87,7 @@ class BufferedSubFile(object):
def unreadline(self, line):
# Let the consumer push a line back into the buffer.
+ assert line is not NeedMoreData
self._lines.append(line)
def push(self, data):
@@ -242,8 +243,18 @@ class FeedParser:
# EOF. We want to see if we're at the end of this subpart, so
# first consume the blank line, then test the next line to see
# if we're at this subpart's EOF.
- line = self._input.readline()
- line = self._input.readline()
+ while True:
+ line = self._input.readline()
+ if line is NeedMoreData:
+ yield NeedMoreData
+ continue
+ break
+ while True:
+ line = self._input.readline()
+ if line is NeedMoreData:
+ yield NeedMoreData
+ continue
+ break
if line == '':
break
# Not at EOF so this is a line we're going to need.