diff options
author | Markus Armbruster <armbru@redhat.com> | 2018-08-23 18:40:07 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2018-08-24 20:26:37 +0200 |
commit | f7617d45d4652ae10d38bd0c917d7488d155cccb (patch) | |
tree | 73d1c4fe8d4bc7095d538bca6ab6867e4154ea60 /tests/check-qjson.c | |
parent | 84a56f38b23440cb3127eaffe4e495826a29f18c (diff) | |
download | qemu-f7617d45d4652ae10d38bd0c917d7488d155cccb.zip qemu-f7617d45d4652ae10d38bd0c917d7488d155cccb.tar.gz qemu-f7617d45d4652ae10d38bd0c917d7488d155cccb.tar.bz2 |
json: Leave rejecting invalid interpolation to parser
Both lexer and parser reject invalid interpolation specifications.
The parser's check is useless.
The lexer ends the token right after the first bad character. This
tends to lead to suboptimal error reporting. For instance, input
[ %04d ]
produces the tokens
JSON_LSQUARE [
JSON_ERROR %0
JSON_INTEGER 4
JSON_KEYWORD d
JSON_RSQUARE ]
The parser then yields an error, an object and two more errors:
error: Invalid JSON syntax
object: 4
error: JSON parse error, invalid keyword
error: JSON parse error, expecting value
Dumb down the lexer to accept [A-Za-z0-9]*. The parser's check is now
used. Emit a proper error there.
The lexer now produces
JSON_LSQUARE [
JSON_INTERP %04d
JSON_RSQUARE ]
and the parser reports just
JSON parse error, invalid interpolation '%04d'
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180823164025.12553-41-armbru@redhat.com>
Diffstat (limited to 'tests/check-qjson.c')
-rw-r--r-- | tests/check-qjson.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/check-qjson.c b/tests/check-qjson.c index d6fda07..83f8a0e 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -1021,7 +1021,8 @@ static void interpolation_unknown(void) } g_test_trap_subprocess(NULL, 0, 0); g_test_trap_assert_failed(); - g_test_trap_assert_stderr("*Unexpected error*stray '%x'*"); + g_test_trap_assert_stderr("*Unexpected error*" + "invalid interpolation '%x'*"); } static void interpolation_string(void) |