Barry Warsaw  committed e218475

_parsebody(): Use get_content_type() instead of the deprecated
get_type(). Also, one of the regular expressions is constant so might
as well make it a module global. And, when splitting up digests,
handle lineseps that are longer than 1 character in length
(e.g. \r\n).

  • Participants
  • Parent commits 88c1c4d
  • Branches 2.2

Comments (0)

Files changed (1)

File Lib/email/

     True = 1
     False = 0
+nlcre = re.compile('\r\n|\r|\n')
 class Parser:
         # Parse the body, but first split the payload on the content-type
         # boundary if present.
         boundary = container.get_boundary()
-        isdigest = (container.get_type() == 'multipart/digest')
+        isdigest = (container.get_content_type() == 'multipart/digest')
         # If there's a boundary, split the payload text into its constituent
         # parts and parse each separately.  Otherwise, just parse the rest of
         # the body as a single message.  Note: any exceptions raised in the
                 preamble = payload[0:start]
             # Find out what kind of line endings we're using
             start += len('sep')) + len('ws'))
-            cre = re.compile('\r\n|\r|\n')
-            mo =, start)
+            mo =, start)
             if mo:
                 start += len(
             # We create a compiled regexp first because we need to be able to
             for part in parts:
                 if isdigest:
-                    if part[0] == linesep:
+                    if part.startswith(linesep):
                         # There's no header block so create an empty message
                         # object as the container, and lop off the newline so
                         # we can parse the sub-subobject
                         msgobj = self._class()
-                        part = part[1:]
+                        part = part[len(linesep):]
                         parthdrs, part = part.split(linesep+linesep, 1)
                         # msgobj in this case is the "message/rfc822" container