diff -bu -r email/errors.py email.patch//errors.py --- email/errors.py 2011-06-11 17:46:24.000000000 +0200 +++ email.patch//errors.py 2011-07-27 18:00:31.512711690 +0200 @@ -44,6 +44,9 @@ class StartBoundaryNotFoundDefect(MessageDefect): """The claimed start boundary was never found.""" +class CloseBoundaryNotFoundDefect(MessageDefect): + """The claimed start boundary was never found.""" + class FirstHeaderLineIsContinuationDefect(MessageDefect): """A message had a continuation line as its first header line.""" diff -bu -r email/feedparser.py email.patch//feedparser.py --- email/feedparser.py 2011-06-11 17:46:24.000000000 +0200 +++ email.patch//feedparser.py 2011-07-27 18:00:31.512711690 +0200 @@ -304,6 +304,7 @@ capturing_preamble = True preamble = [] linesep = False + is_boundary_closed = False while True: line = self._input.readline() if line is NeedMoreData: @@ -318,6 +319,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 +389,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 + self._cur.defects.append(errors.StartBoundaryNotFoundDefect()) if capturing_preamble: self._cur.defects.append(errors.StartBoundaryNotFoundDefect()) self._cur.set_payload(EMPTYSTRING.join(preamble))