Merge pull request #986 from anon5376/codex/tokener-reset-surrogate

tokener: clear pending surrogate on reset
This commit is contained in:
Eric Hawicz authored and GitHub committed 2026-10-25 12:02:52 -04:00
commit 174d76e74e
3 files changed
+16 -1

No files matched your search

+1
View File
@@ -214,6 +214,7 @@ void json_tokener_reset(struct json_tokener *tok)
json_tokener_reset_level(tok, i); json_tokener_reset_level(tok, i);
tok->depth = 0; tok->depth = 0;
tok->err = json_tokener_success; tok->err = json_tokener_success;
tok->high_surrogate = 0;
} }
struct json_object *json_tokener_parse(const char *str) struct json_object *json_tokener_parse(const char *str)
+8
View File
@@ -335,6 +335,14 @@ struct incremental_step
{"{ \"foo", -1, -1, json_tokener_continue, 1, 0}, {"{ \"foo", -1, -1, json_tokener_continue, 1, 0},
{": \"bar\"}", -1, 0, json_tokener_error_parse_unexpected, 1, 0}, {": \"bar\"}", -1, 0, json_tokener_error_parse_unexpected, 1, 0},
/* Reset must discard a pending high surrogate from the previous document. */
{"\"\\uD834", -1, -1, json_tokener_continue, 1, 0},
{"\"\\u0041\"", -1, -1, json_tokener_success, 1, 0},
{"\"\\uD834", -1, -1, json_tokener_continue, 1, 0},
{"\"\\uDD1E\"", -1, -1, json_tokener_success, 1, 0},
{"\"\\uD834\\uZZZZ\"", -1, 9, json_tokener_error_parse_string, 1, 0},
{"\"\\u0041\"", -1, -1, json_tokener_success, 1, 0},
/* Check a supplemental code point that looks like a high surrogate */ /* Check a supplemental code point that looks like a high surrogate */
{"\"\\uD836", -1, -1, json_tokener_continue, 0, 0}, {"\"\\uD836", -1, -1, json_tokener_continue, 0, 0},
{"\\uDE87", -1, -1, json_tokener_continue, 0, 0}, {"\\uDE87", -1, -1, json_tokener_continue, 0, 0},
+7 -1
View File
@@ -140,6 +140,12 @@ json_tokener_parse_ex(tok, "ä" , 4) ... OK: got object of type [string
json_tokener_parse_ex(tok, "ä" , 4) ... OK: got object of type [string]: "ä" json_tokener_parse_ex(tok, "ä" , 4) ... OK: got object of type [string]: "ä"
json_tokener_parse_ex(tok, { "foo , 6) ... OK: got correct error: continue json_tokener_parse_ex(tok, { "foo , 6) ... OK: got correct error: continue
json_tokener_parse_ex(tok, : "bar"} , 8) ... OK: got correct error: unexpected character json_tokener_parse_ex(tok, : "bar"} , 8) ... OK: got correct error: unexpected character
json_tokener_parse_ex(tok, "\uD834 , 7) ... OK: got correct error: continue
json_tokener_parse_ex(tok, "\u0041" , 8) ... OK: got object of type [string]: "A"
json_tokener_parse_ex(tok, "\uD834 , 7) ... OK: got correct error: continue
json_tokener_parse_ex(tok, "\uDD1E" , 8) ... OK: got object of type [string]: "�"
json_tokener_parse_ex(tok, "\uD834\uZZZZ", 14) ... OK: got correct error: invalid string sequence
json_tokener_parse_ex(tok, "\u0041" , 8) ... OK: got object of type [string]: "A"
json_tokener_parse_ex(tok, "\uD836 , 7) ... OK: got correct error: continue json_tokener_parse_ex(tok, "\uD836 , 7) ... OK: got correct error: continue
json_tokener_parse_ex(tok, \uDE87 , 6) ... OK: got correct error: continue json_tokener_parse_ex(tok, \uDE87 , 6) ... OK: got correct error: continue
json_tokener_parse_ex(tok, " , 1) ... OK: got object of type [string]: "�" json_tokener_parse_ex(tok, " , 1) ... OK: got object of type [string]: "�"
@@ -388,5 +394,5 @@ json_tokener_parse_ex(tok, {"":1} , 7) ... OK: got correct error: invalid
json_tokener_parse_ex(tok, {"":1} , 7) ... OK: got correct error: invalid string sequence json_tokener_parse_ex(tok, {"":1} , 7) ... OK: got correct error: invalid string sequence
json_tokener_parse_ex(tok, {"":1} , 7) ... OK: got correct error: invalid string sequence json_tokener_parse_ex(tok, {"":1} , 7) ... OK: got correct error: invalid string sequence
json_tokener_parse_ex(tok, {"":1} , 7) ... OK: got correct error: invalid string sequence json_tokener_parse_ex(tok, {"":1} , 7) ... OK: got correct error: invalid string sequence
End Incremental Tests OK=292 ERROR=0 End Incremental Tests OK=298 ERROR=0
================================== ==================================