]> granicus.if.org Git - python/commitdiff
#10004: in Q encoded word ignore '=xx' when xx is not valid hex.
authorR. David Murray <rdmurray@bitdance.com>
Fri, 1 Oct 2010 15:40:20 +0000 (15:40 +0000)
committerR. David Murray <rdmurray@bitdance.com>
Fri, 1 Oct 2010 15:40:20 +0000 (15:40 +0000)
Bug report and fix by Thomas Guettler.

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

index 12df02883888ec2def7db5e45c96234997cb9939..168dfffa4784a56f06d3345d2774f93ccc457d51 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 e18ffaf9f5a86119b3af654210fe124125a43bdd..b6e4831a04b22e2c206d66e44453f4c1124cd556 100644 (file)
@@ -1659,6 +1659,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 8e99376af47fbb17ddb5d066b61e1c472006d519..3aa6a6d43a4a427ff91d2773afed5086cd3ca5ca 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -79,6 +79,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 #1491: BaseHTTPServer nows send a 100 Continue response before sending
   a 200 OK for the Expect: 100-continue request header.