Merge pull request #3006 from tony-jinwoo-ahn/utf

Fix range of "invalid start byte" for UTF-8
This commit is contained in:
Jeong YunWon
2021-09-05 01:35:05 +09:00
committed by GitHub
2 changed files with 1 additions and 3 deletions

View File

@@ -1896,8 +1896,6 @@ class UnicodeTest(string_tests.CommonTest,
self.assertEqual((b'aaaa' + seq + b'bbbb').decode('utf-8', 'ignore'),
'aaaa' + res + 'bbbb')
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_invalid_start_byte(self):
"""
Test that an 'invalid start byte' error is raised when the first byte

View File

@@ -89,7 +89,7 @@ pub mod utf8 {
let err_idx = remaining_index + e.valid_up_to();
remaining_data = rest;
remaining_index += valid_prefix.len();
if (0x80..0xc0).contains(&first_err) {
if (0x80..0xc2).contains(&first_err) || (0xf5..=0xff).contains(&first_err) {
handle_error!(err_idx..err_idx + 1, "invalid start byte");
}
let err_len = match e.error_len() {