diff -bu email.dist//errors.py email/errors.py --- email.dist//errors.py 2011-08-17 14:37:39.903297773 +0200 +++ email/errors.py 2011-08-17 14:35:29.423297806 +0200 @@ -44,6 +44,9 @@ class StartBoundaryNotFoundDefect(MessageDefect): """The claimed start boundary was never found.""" +class CloseBoundaryNotFoundDefect(MessageDefect): + """The claimed stop boundary was never found.""" + class FirstHeaderLineIsContinuationDefect(MessageDefect): """A message had a continuation line as its first header line.""" @@ -55,3 +58,6 @@ class MultipartInvariantViolationDefect(MessageDefect): """A message claimed to be a multipart but no subparts were found.""" + +class MissingHeaderBodySeparator(MessageDefect): + """The header/body separator (eg:new line) is missing""" diff -bu email.dist//feedparser.py email/feedparser.py --- email.dist//feedparser.py 2011-08-17 14:37:39.903297773 +0200 +++ email/feedparser.py 2011-08-17 14:32:55.603297845 +0200 @@ -207,6 +207,7 @@ # (i.e. newline), just throw it away. Otherwise the line is # part of the body so push it back. if not NLCRE.match(line): + self._cur.defects.append(errors.MissingHeaderBodySeparator()) self._input.unreadline(line) break headers.append(line) @@ -304,6 +305,7 @@ capturing_preamble = True preamble = [] linesep = False + is_boundary_closed = False while True: line = self._input.readline() if line is NeedMoreData: @@ -318,6 +320,7 @@ # the closing boundary, then we need to initialize the # epilogue with the empty string (see below). if mo.group('end'): + is_boundary_closed = True linesep = mo.group('linesep') break # We saw an inter-part boundary. Were we in the preamble? @@ -387,6 +390,10 @@ # 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 is_boundary_closed is False: + self._cur.defects.append(errors.CloseBoundaryNotFoundDefect()) + return + if capturing_preamble: self._cur.defects.append(errors.StartBoundaryNotFoundDefect()) self._cur.set_payload(EMPTYSTRING.join(preamble)) Common subdirectories: email.dist//mime and email/mime Common subdirectories: email.dist//test and email/test