Mailing List Archive

python/dist/src/Lib/email Parser.py,1.5.10.2,1.5.10.3
Update of /cvsroot/python/python/dist/src/Lib/email
In directory usw-pr-cvs1:/tmp/cvs-serv17633/Lib/email

Modified Files:
Tag: release22-maint
Parser.py
Log Message:
_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).


Index: Parser.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/Parser.py,v
retrieving revision 1.5.10.2
retrieving revision 1.5.10.3
diff -C2 -d -r1.5.10.2 -r1.5.10.3
*** Parser.py 4 Oct 2002 17:24:24 -0000 1.5.10.2
--- Parser.py 7 Oct 2002 17:02:40 -0000 1.5.10.3
***************
*** 21,24 ****
--- 21,26 ----
False = 0

+ nlcre = re.compile('\r\n|\r|\n')
+


***************
*** 138,142 ****
# boundary if present.
boundary = container.get_boundary()
! isdigest = (container.get_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
--- 140,144 ----
# boundary if present.
boundary = container.get_boundary()
! 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
***************
*** 168,173 ****
# Find out what kind of line endings we're using
start += len(mo.group('sep')) + len(mo.group('ws'))
! cre = re.compile('\r\n|\r|\n')
! mo = cre.search(payload, start)
if mo:
start += len(mo.group(0))
--- 170,174 ----
# Find out what kind of line endings we're using
start += len(mo.group('sep')) + len(mo.group('ws'))
! mo = nlcre.search(payload, start)
if mo:
start += len(mo.group(0))
***************
*** 210,219 ****
for part in parts:
if isdigest:
! if part[0] == 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:]
else:
parthdrs, part = part.split(linesep+linesep, 1)
--- 211,220 ----
for part in parts:
if isdigest:
! 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[len(linesep):]
else:
parthdrs, part = part.split(linesep+linesep, 1)