]> git.proxmox.com Git - mirror_qemu.git/commit - qobject/json-lexer.c
json: Treat unwanted interpolation as lexical error
authorMarkus Armbruster <armbru@redhat.com>
Thu, 23 Aug 2018 16:40:05 +0000 (18:40 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Fri, 24 Aug 2018 18:26:37 +0000 (20:26 +0200)
commit2cbd15aa6f4d4694376dd0d231d56e572ac870c1
tree80bffd7131ee398510fb7961dfc0cb2982bed852
parent61030280ca2d67bd63cb068250aee55849cd38ca
json: Treat unwanted interpolation as lexical error

The JSON parser optionally supports interpolation.  The lexer
recognizes interpolation tokens unconditionally.  The parser rejects
them when interpolation is disabled, in parse_interpolation().
However, it neglects to set an error then, which can make
json_parser_parse() fail without setting an error.

Move the check for unwanted interpolation from the parser's
parse_interpolation() into the lexer's finite state machine.  When
interpolation is disabled, '%' is now handled like any other
unexpected character.

The next commit will improve how such lexical errors are handled.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180823164025.12553-39-armbru@redhat.com>
include/qapi/qmp/json-lexer.h
qobject/json-lexer.c
qobject/json-parser.c
qobject/json-streamer.c
tests/qmp-test.c