mirror of https://github.com/python/cpython
#2242: utf7 decoding crashes on bogus input on some Windows/MSVC versions
This commit is contained in:
parent
5255cba4bc
commit
4982d5d04a
|
@ -532,6 +532,9 @@ class UnicodeTest(
|
||||||
|
|
||||||
self.assertEqual(unicode('+3ADYAA-', 'utf-7', 'replace'), u'\ufffd')
|
self.assertEqual(unicode('+3ADYAA-', 'utf-7', 'replace'), u'\ufffd')
|
||||||
|
|
||||||
|
# Issue #2242: crash on some Windows/MSVC versions
|
||||||
|
self.assertRaises(UnicodeDecodeError, '+\xc1'.decode, 'utf-7')
|
||||||
|
|
||||||
def test_codecs_utf8(self):
|
def test_codecs_utf8(self):
|
||||||
self.assertEqual(u''.encode('utf-8'), '')
|
self.assertEqual(u''.encode('utf-8'), '')
|
||||||
self.assertEqual(u'\u20ac'.encode('utf-8'), '\xe2\x82\xac')
|
self.assertEqual(u'\u20ac'.encode('utf-8'), '\xe2\x82\xac')
|
||||||
|
|
|
@ -1523,7 +1523,7 @@ PyObject *PyUnicode_DecodeUTF7Stateful(const char *s,
|
||||||
while (s < e) {
|
while (s < e) {
|
||||||
Py_UNICODE ch;
|
Py_UNICODE ch;
|
||||||
restart:
|
restart:
|
||||||
ch = *s;
|
ch = (unsigned char) *s;
|
||||||
|
|
||||||
if (inShift) {
|
if (inShift) {
|
||||||
if ((ch == '-') || !B64CHAR(ch)) {
|
if ((ch == '-') || !B64CHAR(ch)) {
|
||||||
|
|
Loading…
Reference in New Issue