]> granicus.if.org Git - python/commitdiff
_parsebody(): Instead of raising a BoundaryError when no start
authorBarry Warsaw <barry@python.org>
Tue, 10 Sep 2002 16:14:56 +0000 (16:14 +0000)
committerBarry Warsaw <barry@python.org>
Tue, 10 Sep 2002 16:14:56 +0000 (16:14 +0000)
boundary could be found -- in a lax parser -- the entire body is
assigned to the message payload.

Lib/email/Parser.py

index a2ac576436bc1178edf85e55658dca48b87b3a3d..869ef1618d2ea37042536b6a360fb68ec16a75db 100644 (file)
@@ -135,8 +135,11 @@ class Parser:
                 r'(?P<sep>' + re.escape(separator) + r')(?P<ws>[ \t]*)',
                 payload)
             if not mo:
-                raise Errors.BoundaryError(
-                    "Couldn't find starting boundary: %s" % boundary)
+                if self._strict:
+                    raise Errors.BoundaryError(
+                        "Couldn't find starting boundary: %s" % boundary)
+                container.set_payload(payload)
+                return
             start = mo.start()
             if start > 0:
                 # there's some pre-MIME boundary preamble