]> granicus.if.org Git - python/commitdiff
Merged revisions 85142 via svnmerge from
authorR. David Murray <rdmurray@bitdance.com>
Fri, 1 Oct 2010 15:45:48 +0000 (15:45 +0000)
committerR. David Murray <rdmurray@bitdance.com>
Fri, 1 Oct 2010 15:45:48 +0000 (15:45 +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 bf28d3980dbcac7c05628a9654eeea4eb7644e70..85efc088aa2a4ec2a4a2adebd7bdfd1eaa303f12 100644 (file)
@@ -294,4 +294,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, re.ASCII)
+    return re.sub(r'=[a-fA-F0-9]{2}', _unquote_match, s, re.ASCII)
index d5ac9c4511fae8d21b001c57c81dc6052fe984ed..42a2ee3b2fa8dee5ef09658b83ab9fd6ba21373c 100644 (file)
@@ -1655,6 +1655,12 @@ Re: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz foo bar =?mac-iceland?q?r=8Aksm?=
             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 231ca55ed2ba0a9b884f5f42a29ea3ea63d7b2df..8781c0028cd06ec878f5f6edcfa7ca88b4bfd9f3 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -121,6 +121,9 @@ C-API
 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