[Python-checkins] python/dist/src/Lib/email Utils.py,1.21,1.22

bwarsaw@users.sourceforge.net bwarsaw@users.sourceforge.net
Fri, 07 Mar 2003 14:46:44 -0800


Update of /cvsroot/python/python/dist/src/Lib/email
In directory sc8-pr-cvs1:/tmp/cvs-serv27678

Modified Files:
	Utils.py 
Log Message:
decode_rfc2231(): RFC 2231 allows leaving out both the charset and
language without including any single quotes.


Index: Utils.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/Utils.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** Utils.py	5 Nov 2002 19:54:21 -0000	1.21
--- Utils.py	7 Mar 2003 22:46:41 -0000	1.22
***************
*** 281,287 ****
      """Decode string according to RFC 2231"""
      import urllib
!     charset, language, s = s.split("'", 2)
!     s = urllib.unquote(s)
!     return charset, language, s
  
  
--- 281,289 ----
      """Decode string according to RFC 2231"""
      import urllib
!     parts = s.split("'", 2)
!     if len(parts) == 1:
!         return None, None, s
!     charset, language, s = parts
!     return charset, language, urllib.unquote(s)
  
  
***************
*** 336,340 ****
                  value.append(continuation)
              charset, language, value = decode_rfc2231(EMPTYSTRING.join(value))
!             new_params.append((name,
!                                (charset, language, '"%s"' % quote(value))))
      return new_params
--- 338,342 ----
                  value.append(continuation)
              charset, language, value = decode_rfc2231(EMPTYSTRING.join(value))
!             new_params.append(
!                 (name, (charset, language, '"%s"' % quote(value))))
      return new_params