]> granicus.if.org Git - python/commitdiff
Merged revisions 65227 via svnmerge from
authorAntoine Pitrou <solipsis@pitrou.net>
Fri, 25 Jul 2008 18:05:24 +0000 (18:05 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Fri, 25 Jul 2008 18:05:24 +0000 (18:05 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r65227 | antoine.pitrou | 2008-07-25 19:45:59 +0200 (ven., 25 juil. 2008) | 3 lines

  #2242: utf7 decoding crashes on bogus input on some Windows/MSVC versions
........

Lib/test/test_unicode.py
Objects/unicodeobject.c

index e6b3cb0bed0098ffaf0c0f3a732d441872b4499c..604fdf28ed40a8dafe109bb4226276dbcb045dfc 100644 (file)
@@ -847,6 +847,9 @@ class UnicodeTest(
 
         self.assertEqual(str(b'+3ADYAA-', 'utf-7', 'replace'), '\ufffd')
 
+        # Issue #2242: crash on some Windows/MSVC versions
+        self.assertRaises(UnicodeDecodeError, b'+\xc1'.decode, 'utf-7')
+
     def test_codecs_utf8(self):
         self.assertEqual(''.encode('utf-8'), b'')
         self.assertEqual('\u20ac'.encode('utf-8'), b'\xe2\x82\xac')
index b0b525ae893d072c1c18df2bdac8704764733349..838f537e02bf3e23eb12c0a90727c0168d296599 100644 (file)
@@ -1727,7 +1727,7 @@ PyObject *PyUnicode_DecodeUTF7Stateful(const char *s,
     while (s < e) {
         Py_UNICODE ch;
         restart:
-        ch = *s;
+        ch = (unsigned char) *s;
 
         if (inShift) {
             if ((ch == '-') || !B64CHAR(ch)) {