summaryrefslogtreecommitdiffstats
path: root/Lib/email/FeedParser.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2004-11-28 00:21:42 (GMT)
committerBarry Warsaw <barry@python.org>2004-11-28 00:21:42 (GMT)
commit2e8c1f189a497179b7fd7bd5dad61c3189167849 (patch)
treed155df0293d728c40f6822689a28c990eb4dd633 /Lib/email/FeedParser.py
parentf7f9b6cb2df7a933f687622044a86cd49a7d9f9b (diff)
downloadcpython-2e8c1f189a497179b7fd7bd5dad61c3189167849.zip
cpython-2e8c1f189a497179b7fd7bd5dad61c3189167849.tar.gz
cpython-2e8c1f189a497179b7fd7bd5dad61c3189167849.tar.bz2
Fix for SF bug #1072623. When the last line of the input string does not end
in a newline, and it's an end boundary, the FeedParser wasn't recognizing it as such. Tweak the regexp to make the ending linesep optional. For grins, clear self._partial when closing the BufferedSubFile. Added a test case.
Diffstat (limited to 'Lib/email/FeedParser.py')
-rw-r--r--Lib/email/FeedParser.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/email/FeedParser.py b/Lib/email/FeedParser.py
index 1d6e3dd..690b7c2 100644
--- a/Lib/email/FeedParser.py
+++ b/Lib/email/FeedParser.py
@@ -62,6 +62,7 @@ class BufferedSubFile(object):
def close(self):
# Don't forget any trailing partial line.
self._lines.append(self._partial)
+ self._partial = ''
self._closed = True
def readline(self):
@@ -279,7 +280,7 @@ class FeedParser:
separator = '--' + boundary
boundaryre = re.compile(
'(?P<sep>' + re.escape(separator) +
- r')(?P<end>--)?(?P<ws>[ \t]*)(?P<linesep>\r\n|\r|\n)$')
+ r')(?P<end>--)?(?P<ws>[ \t]*)(?P<linesep>\r\n|\r|\n)?$')
capturing_preamble = True
preamble = []
linesep = False