[Python-checkins] r85143 - in python/branches/release31-maint: Lib/email/quoprimime.py Lib/email/test/test_email.py Misc/NEWS

r.david.murray python-checkins at python.org
Fri Oct 1 17:45:48 CEST 2010


Author: r.david.murray
Date: Fri Oct  1 17:45:48 2010
New Revision: 85143

Log:
Merged revisions 85142 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r85142 | r.david.murray | 2010-10-01 11:40:20 -0400 (Fri, 01 Oct 2010) | 5 lines
  
  #10004: in Q encoded word ignore '=xx' when xx is not valid hex.
  
  Bug report and fix by Thomas Guettler.
........


Modified:
   python/branches/release31-maint/   (props changed)
   python/branches/release31-maint/Lib/email/quoprimime.py
   python/branches/release31-maint/Lib/email/test/test_email.py
   python/branches/release31-maint/Misc/NEWS

Modified: python/branches/release31-maint/Lib/email/quoprimime.py
==============================================================================
--- python/branches/release31-maint/Lib/email/quoprimime.py	(original)
+++ python/branches/release31-maint/Lib/email/quoprimime.py	Fri Oct  1 17:45:48 2010
@@ -294,4 +294,4 @@
     the high level email.Header class for that functionality.
     """
     s = s.replace('_', ' ')
-    return re.sub(r'=\w{2}', _unquote_match, s, re.ASCII)
+    return re.sub(r'=[a-fA-F0-9]{2}', _unquote_match, s, re.ASCII)

Modified: python/branches/release31-maint/Lib/email/test/test_email.py
==============================================================================
--- python/branches/release31-maint/Lib/email/test/test_email.py	(original)
+++ python/branches/release31-maint/Lib/email/test/test_email.py	Fri Oct  1 17:45:48 2010
@@ -1655,6 +1655,12 @@
             dh = decode_header(s % q)
             self.assertEqual(dh, [(a, 'iso-8859-1')])
 
+    def test_rfc2047_Q_invalid_digits(self):
+        # issue 10004.
+        s = '=?iso-8659-1?Q?andr=e9=zz?='
+        self.assertEqual(decode_header(s),
+                        [(b'andr\xe9=zz', 'iso-8659-1')])
+
 
 # Test the MIMEMessage class
 class TestMIMEMessage(TestEmailBase):

Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS	(original)
+++ python/branches/release31-maint/Misc/NEWS	Fri Oct  1 17:45:48 2010
@@ -121,6 +121,9 @@
 Library
 -------
 
+- Issue #10004: quoprimime no longer generates a traceback when confronted
+  with invalid characters after '=' in a Q-encoded word.
+
 - Issue #9950: Fix socket.sendall() crash or misbehaviour when a signal is
   received.  Now sendall() properly calls signal handlers if necessary,
   and retries sending if these returned successfully, including on sockets


More information about the Python-checkins mailing list