summaryrefslogtreecommitdiffstats
path: root/Lib/email/feedparser.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2012-05-28 02:20:42 (GMT)
committerR David Murray <rdmurray@bitdance.com>2012-05-28 02:20:42 (GMT)
commit7ef3ff3f2ea77f496f5386c3ede74f95001a6009 (patch)
treeab17160f5d03de8fa54f02ceb2b38e3f769156a1 /Lib/email/feedparser.py
parentd0a0e8e070f1c3c74905627380473f21f5457cfb (diff)
downloadcpython-7ef3ff3f2ea77f496f5386c3ede74f95001a6009.zip
cpython-7ef3ff3f2ea77f496f5386c3ede74f95001a6009.tar.gz
cpython-7ef3ff3f2ea77f496f5386c3ede74f95001a6009.tar.bz2
#12515: email now registers a defect if the MIME end boundary is missing.
This commit also restores the news item for 167256 that it looks like Terry inadvertently deleted. (Either that, or I don't understand now merging works...which is equally possible.)
Diffstat (limited to 'Lib/email/feedparser.py')
-rw-r--r--Lib/email/feedparser.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/Lib/email/feedparser.py b/Lib/email/feedparser.py
index c3a67c0..56f50df 100644
--- a/Lib/email/feedparser.py
+++ b/Lib/email/feedparser.py
@@ -324,6 +324,7 @@ class FeedParser:
capturing_preamble = True
preamble = []
linesep = False
+ close_boundary_seen = False
while True:
line = self._input.readline()
if line is NeedMoreData:
@@ -338,6 +339,7 @@ class FeedParser:
# the closing boundary, then we need to initialize the
# epilogue with the empty string (see below).
if mo.group('end'):
+ close_boundary_seen = True
linesep = mo.group('linesep')
break
# We saw an inter-part boundary. Were we in the preamble?
@@ -406,7 +408,6 @@ class FeedParser:
# We've seen either the EOF or the end boundary. If we're still
# capturing the preamble, we never saw the start boundary. Note
# that as a defect and store the captured text as the payload.
- # Everything from here to the EOF is epilogue.
if capturing_preamble:
defect = errors.StartBoundaryNotFoundDefect()
self.policy.handle_defect(self._cur, defect)
@@ -418,8 +419,15 @@ class FeedParser:
continue
self._cur.epilogue = EMPTYSTRING.join(epilogue)
return
- # If the end boundary ended in a newline, we'll need to make sure
- # the epilogue isn't None
+ # If we're not processing the preamble, then we might have seen
+ # EOF without seeing that end boundary...that is also a defect.
+ if not close_boundary_seen:
+ defect = errors.CloseBoundaryNotFoundDefect()
+ self.policy.handle_defect(self._cur, defect)
+ return
+ # Everything from here to the EOF is epilogue. If the end boundary
+ # ended in a newline, we'll need to make sure the epilogue isn't
+ # None
if linesep:
epilogue = ['']
else: