Skip to content
Snippets Groups Projects
Commit 7c85c7c2 authored by Damien George's avatar Damien George
Browse files

py/unicode: Fix check for valid utf8 being stricter about contn chars.

parent d63ef86c
No related branches found
No related tags found
No related merge requests found
...@@ -180,7 +180,7 @@ bool utf8_check(const byte *p, size_t len) { ...@@ -180,7 +180,7 @@ bool utf8_check(const byte *p, size_t len) {
for (; p < end; p++) { for (; p < end; p++) {
byte c = *p; byte c = *p;
if (need) { if (need) {
if (c >= 0x80) { if (UTF8_IS_CONT(c)) {
need--; need--;
} else { } else {
// mismatch // mismatch
......
...@@ -47,3 +47,7 @@ try: ...@@ -47,3 +47,7 @@ try:
str(bytearray(b'ab\xc0a'), 'utf8') str(bytearray(b'ab\xc0a'), 'utf8')
except UnicodeError: except UnicodeError:
print('UnicodeError') print('UnicodeError')
try:
str(b'\xf0\xe0\xed\xe8', 'utf8')
except UnicodeError:
print('UnicodeError')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment