mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
check-qjson qmp-test: Cover control characters more thoroughly
RFC 8259 "The JavaScript Object Notation (JSON) Data Interchange Format" requires control characters in strings to be escaped. Demonstrate the JSON parser accepts U+0001 .. U+001F unescaped. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180823164025.12553-16-armbru@redhat.com>
This commit is contained in:
parent
5f454e662e
commit
6bc93a3401
2 changed files with 44 additions and 6 deletions
|
@ -71,6 +71,13 @@ static void test_malformed(QTestState *qts)
|
|||
qobject_unref(resp);
|
||||
g_assert(recovered(qts));
|
||||
|
||||
/* lexical error: funny control character outside string */
|
||||
qtest_qmp_send_raw(qts, "{\x01");
|
||||
resp = qtest_qmp_receive(qts);
|
||||
g_assert_cmpstr(get_error_class(resp), ==, "GenericError");
|
||||
qobject_unref(resp);
|
||||
g_assert(recovered(qts));
|
||||
|
||||
/* lexical error: impossible byte in string */
|
||||
qtest_qmp_send_raw(qts, "{'bad \xFF");
|
||||
resp = qtest_qmp_receive(qts);
|
||||
|
@ -78,6 +85,13 @@ static void test_malformed(QTestState *qts)
|
|||
qobject_unref(resp);
|
||||
g_assert(recovered(qts));
|
||||
|
||||
/* lexical error: control character in string */
|
||||
qtest_qmp_send_raw(qts, "{'execute': 'nonexistent', 'id':'\n'}");
|
||||
resp = qtest_qmp_receive(qts);
|
||||
g_assert_cmpstr(get_error_class(resp), ==, "CommandNotFound"); /* BUG */
|
||||
qobject_unref(resp);
|
||||
g_assert(recovered(qts));
|
||||
|
||||
/* lexical error: interpolation */
|
||||
qtest_qmp_send_raw(qts, "%%p\n");
|
||||
resp = qtest_qmp_receive(qts);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue