#14925: email now registers a defect for missing header/body separator.

This patch also deprecates the MalformedHeaderDefect.  My best guess is that
this defect was rendered obsolete by a refactoring of the parser, and the
corresponding defect for the new parser (which this patch introduces) was
overlooked.
This commit is contained in:
R David Murray 2012-05-27 20:45:01 -04:00
parent 2c172d04bb
commit adbdcdbd95
6 changed files with 61 additions and 18 deletions

View file

@ -219,6 +219,8 @@ class FeedParser:
# (i.e. newline), just throw it away. Otherwise the line is
# part of the body so push it back.
if not NLCRE.match(line):
defect = errors.MissingHeaderBodySeparatorDefect()
self.policy.handle_defect(self._cur, defect)
self._input.unreadline(line)
break
headers.append(line)
@ -488,12 +490,10 @@ class FeedParser:
self._cur.defects.append(defect)
continue
# Split the line on the colon separating field name from value.
# There will always be a colon, because if there wasn't the part of
# the parser that calls us would have started parsing the body.
i = line.find(':')
if i < 0:
defect = errors.MalformedHeaderDefect(line)
# XXX: fixme (defect not going through policy)
self._cur.defects.append(defect)
continue
assert i>0, "_parse_headers fed line with no : and no leading WS"
lastheader = line[:i]
lastvalue = [line]
# Done with all the lines, so handle the last header.