Issue #867 - also disallow control characters in keys

This commit is contained in:
Eric Hawicz
2025-04-03 21:09:05 -04:00
parent 7bca694b47
commit 7cee5237dc
3 changed files with 77 additions and 1 deletions

View File

@@ -1250,6 +1250,12 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char *
state = json_tokener_state_string_escape;
break;
}
else if ((tok->flags & JSON_TOKENER_STRICT) && (unsigned char)c <= 0x1f)
{
// Disallow control characters in strict mode
tok->err = json_tokener_error_parse_string;
goto out;
}
if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok))
{
printbuf_memappend_checked(tok->pb, case_start,