mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
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>
This commit is contained in:
parent
61030280ca
commit
2cbd15aa6f
5 changed files with 25 additions and 19 deletions
|
@ -33,12 +33,12 @@ typedef enum json_token_type {
|
|||
} JSONTokenType;
|
||||
|
||||
typedef struct JSONLexer {
|
||||
int state;
|
||||
int start_state, state;
|
||||
GString *token;
|
||||
int x, y;
|
||||
} JSONLexer;
|
||||
|
||||
void json_lexer_init(JSONLexer *lexer);
|
||||
void json_lexer_init(JSONLexer *lexer, bool enable_interpolation);
|
||||
|
||||
void json_lexer_feed(JSONLexer *lexer, const char *buffer, size_t size);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue