]> granicus.if.org Git - python/commitdiff
Merged revisions 85142 via svnmerge from
authorR. David Murray <rdmurray@bitdance.com>
Fri, 1 Oct 2010 15:48:49 +0000 (15:48 +0000)
committerR. David Murray <rdmurray@bitdance.com>
Fri, 1 Oct 2010 15:48:49 +0000 (15:48 +0000)
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.
........

Lib/email/quoprimime.py
Lib/email/test/test_email.py
Misc/NEWS

index b9dbfa97e044b0357252b209bdf00427104ca828..0c18a9e04efb23beb8d6089d514d0d0a577c6e40 100644 (file)
@@ -333,4 +333,4 @@ def header_decode(s):
     the high level email.header class for that functionality.
     """
     s = s.replace('_', ' ')
-    return re.sub(r'=\w{2}', _unquote_match, s)
+    return re.sub(r'=[a-fA-F0-9]{2}', _unquote_match, s)
index 300fc21711ca89391e7a4a9c60034ce802bf83b4..c3610bf6e24d8433472886e2d27885a86eca7d77 100644 (file)
@@ -1621,6 +1621,12 @@ class TestRFC2047(unittest.TestCase):
             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')])
+
 \f
 # Test the MIMEMessage class
 class TestMIMEMessage(TestEmailBase):
index d30b05b3a6352184a8c4ba6fb6191a8d47475eb2..78eb34f920dcd5f396b22eb04d23067a9553f467 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -48,6 +48,9 @@ Core and Builtins
 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