diff options
author | Barry Warsaw <barry@python.org> | 2004-05-13 20:17:51 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2004-05-13 20:17:51 (GMT) |
commit | 4e59bc1e67e5459858d94b7e9fc41dfb0922ea62 (patch) | |
tree | 710616ad76c7806b6ae5d94d86b134096a95d275 /Lib/email | |
parent | 58eb0fcb8f33e8bfd1f850f42c9efb27e1b48417 (diff) | |
download | cpython-4e59bc1e67e5459858d94b7e9fc41dfb0922ea62.zip cpython-4e59bc1e67e5459858d94b7e9fc41dfb0922ea62.tar.gz cpython-4e59bc1e67e5459858d94b7e9fc41dfb0922ea62.tar.bz2 |
readline(): RFC 2046, section 5.1.2 (and partially 5.1) both state that the
parser must recognize outer boundaries in inner parts. So cruise through the
EOF stack backwards testing each predicate against the current line.
There's still some discussion about whether this is (always) the best thing to
do. Anthony would rather parse these messages as if the outer boundaries were
ignored. I think that's counter to the RFC, but might be practically more
useful. Can you say behavior flag? (ug).
Diffstat (limited to 'Lib/email')
-rw-r--r-- | Lib/email/FeedParser.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/email/FeedParser.py b/Lib/email/FeedParser.py index 294a6a5..ac3769d 100644 --- a/Lib/email/FeedParser.py +++ b/Lib/email/FeedParser.py @@ -71,9 +71,11 @@ class BufferedSubFile(object): # Pop the line off the stack and see if it matches the current # false-EOF predicate. line = self._lines.pop() - if self._eofstack: - matches = self._eofstack[-1] - if matches(line): + # RFC 2046, section 5.1.2 requires us to recognize outer level + # boundaries at any level of inner nesting. Do this, but be sure it's + # in the order of most to least nested. + for ateof in self._eofstack[::-1]: + if ateof(line): # We're at the false EOF. But push the last line back first. self._lines.append(line) return '' |