mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 08:43:55 -06:00
json: Reject unescaped control characters
Fix the lexer to reject unescaped control characters in JSON strings, in accordance with RFC 8259 "The JavaScript Object Notation (JSON) Data Interchange Format". Bonus: we now recover more nicely from unclosed strings. E.g. {"one: 1}\n{"two": 2} now recovers cleanly after the newline, where before the lexer remained confused until the next unpaired double quote or lexical error. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180823164025.12553-19-armbru@redhat.com>
This commit is contained in:
parent
a2ec6be72b
commit
340db1ed82
3 changed files with 5 additions and 9 deletions
|
@ -86,9 +86,9 @@ static void test_malformed(QTestState *qts)
|
|||
g_assert(recovered(qts));
|
||||
|
||||
/* lexical error: control character in string */
|
||||
qtest_qmp_send_raw(qts, "{'execute': 'nonexistent', 'id':'\n'}");
|
||||
qtest_qmp_send_raw(qts, "{'execute': 'nonexistent', 'id':'\n");
|
||||
resp = qtest_qmp_receive(qts);
|
||||
g_assert_cmpstr(get_error_class(resp), ==, "CommandNotFound"); /* BUG */
|
||||
g_assert_cmpstr(get_error_class(resp), ==, "GenericError");
|
||||
qobject_unref(resp);
|
||||
g_assert(recovered(qts));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue