A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/python/cpython/commit/b4bbee25b1e3f4bccac222f806b3138fb72439d6 below:

vulnerability in the utf-16 decoder … · python/cpython@b4bbee2 · GitHub

@@ -540,8 +540,19 @@ def test_partial(self):

540 540

)

541 541 542 542

def test_errors(self):

543 -

self.assertRaises(UnicodeDecodeError, codecs.utf_16_le_decode,

544 -

b"\xff", "strict", True)

543 +

tests = [

544 +

(b'\xff', '\ufffd'),

545 +

(b'A\x00Z', 'A\ufffd'),

546 +

(b'A\x00B\x00C\x00D\x00Z', 'ABCD\ufffd'),

547 +

(b'\x00\xd8', '\ufffd'),

548 +

(b'\x00\xd8A', '\ufffd'),

549 +

(b'\x00\xd8A\x00', '\ufffdA'),

550 +

(b'\x00\xdcA\x00', '\ufffdA'),

551 +

]

552 +

for raw, expected in tests:

553 +

self.assertRaises(UnicodeDecodeError, codecs.utf_16_le_decode,

554 +

raw, 'strict', True)

555 +

self.assertEqual(raw.decode('utf-16le', 'replace'), expected)

545 556 546 557

def test_nonbmp(self):

547 558

self.assertEqual("\U00010203".encode(self.encoding),

@@ -568,8 +579,19 @@ def test_partial(self):

568 579

)

569 580 570 581

def test_errors(self):

571 -

self.assertRaises(UnicodeDecodeError, codecs.utf_16_be_decode,

572 -

b"\xff", "strict", True)

582 +

tests = [

583 +

(b'\xff', '\ufffd'),

584 +

(b'\x00A\xff', 'A\ufffd'),

585 +

(b'\x00A\x00B\x00C\x00DZ', 'ABCD\ufffd'),

586 +

(b'\xd8\x00', '\ufffd'),

587 +

(b'\xd8\x00\xdc', '\ufffd'),

588 +

(b'\xd8\x00\x00A', '\ufffdA'),

589 +

(b'\xdc\x00\x00A', '\ufffdA'),

590 +

]

591 +

for raw, expected in tests:

592 +

self.assertRaises(UnicodeDecodeError, codecs.utf_16_be_decode,

593 +

raw, 'strict', True)

594 +

self.assertEqual(raw.decode('utf-16be', 'replace'), expected)

573 595 574 596

def test_nonbmp(self):

575 597

self.assertEqual("\U00010203".encode(self.encoding),


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4