[Python-checkins] python/dist/src/Lib/email Message.py,1.17,1.18
bwarsaw@users.sourceforge.net
bwarsaw@users.sourceforge.net
Tue, 20 Aug 2002 07:50:12 -0700
Update of /cvsroot/python/python/dist/src/Lib/email
In directory usw-pr-cvs1:/tmp/cvs-serv25168/email
Modified Files:
Message.py
Log Message:
get_content_type(), get_content_maintype(), get_content_subtype(): RFC
2045, section 5.2 states that if the Content-Type: header is
syntactically invalid, the default type should be text/plain.
Implement minimal sanity checking of the header -- it must have
exactly one slash in it. This closes SF patch #597593 by Skip, but in
a different way.
Note that these methods used to raise ValueError for invalid ctypes,
but now they won't.
Index: Message.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/Message.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** Message.py 19 Jul 2002 22:24:55 -0000 1.17
--- Message.py 20 Aug 2002 14:50:09 -0000 1.18
***************
*** 423,427 ****
# This should have no parameters
return self.get_default_type()
! return paramre.split(value)[0].lower().strip()
def get_content_maintype(self):
--- 423,431 ----
# This should have no parameters
return self.get_default_type()
! ctype = paramre.split(value)[0].lower().strip()
! # RFC 2045, section 5.2 says if its invalid, use text/plain
! if ctype.count('/') <> 1:
! return 'text/plain'
! return ctype
def get_content_maintype(self):
***************
*** 433,438 ****
"""
ctype = self.get_content_type()
- if ctype.count('/') <> 1:
- raise ValueError, 'No maintype found in: %s' % ctype
return ctype.split('/')[0]
--- 437,440 ----
***************
*** 445,450 ****
"""
ctype = self.get_content_type()
- if ctype.count('/') <> 1:
- raise ValueError, 'No subtype found in: %s' % ctype
return ctype.split('/')[1]
--- 447,450 ----