[Python-checkins] python/dist/src/Lib/email Message.py,1.28,1.29

bwarsaw@users.sourceforge.net bwarsaw@users.sourceforge.net
Mon, 10 Mar 2003 08:13:23 -0800


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

Modified Files:
	Message.py 
Log Message:
get_payload(): If we get a low-level binascii.Error when base64
decoding the payload, just return it as-is.


Index: Message.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/Message.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** Message.py	10 Oct 2002 15:13:26 -0000	1.28
--- Message.py	10 Mar 2003 16:13:14 -0000	1.29
***************
*** 6,9 ****
--- 6,10 ----
  
  import re
+ import binascii
  import warnings
  from cStringIO import StringIO
***************
*** 11,16 ****
  
  # Intrapackage imports
- from email import Errors
  from email import Utils
  from email import Charset
  
--- 12,17 ----
  
  # Intrapackage imports
  from email import Utils
+ from email import Errors
  from email import Charset
  
***************
*** 170,176 ****
          multipart, the payload will be decoded if this header's value is
          `quoted-printable' or `base64'.  If some other encoding is used, or
!         the header is missing, the payload is returned as-is (undecoded).  If
!         the message is a multipart and the decode flag is True, then None is
!         returned.
          """
          if i is None:
--- 171,179 ----
          multipart, the payload will be decoded if this header's value is
          `quoted-printable' or `base64'.  If some other encoding is used, or
!         the header is missing, or if the payload has bogus base64 data, the
!         payload is returned as-is (undecoded).
! 
!         If the message is a multipart and the decode flag is True, then None
!         is returned.
          """
          if i is None:
***************
*** 187,191 ****
                  return Utils._qdecode(payload)
              elif cte.lower() == 'base64':
!                 return Utils._bdecode(payload)
          # Everything else, including encodings with 8bit or 7bit are returned
          # unchanged.
--- 190,198 ----
                  return Utils._qdecode(payload)
              elif cte.lower() == 'base64':
!                 try:
!                     return Utils._bdecode(payload)
!                 except binascii.Error:
!                     # Incorrect padding
!                     return payload
          # Everything else, including encodings with 8bit or 7bit are returned
          # unchanged.