diff options
author | Michael Roth <mdroth@linux.vnet.ibm.com> | 2011-06-01 12:14:58 -0500 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2011-06-07 13:52:11 -0500 |
commit | b011f61931f0113b29b7cd7e921dd022e0b04834 (patch) | |
tree | e1e2a9a0329d29e8aaa06b06aa0209a3022fc8de /json-lexer.h | |
parent | bd3924a33a66c40065a8fa73b4d7a27aca3b0e04 (diff) | |
download | qemu-b011f61931f0113b29b7cd7e921dd022e0b04834.tar.gz qemu-b011f61931f0113b29b7cd7e921dd022e0b04834.tar.bz2 qemu-b011f61931f0113b29b7cd7e921dd022e0b04834.zip |
json-lexer: make lexer error-recovery more deterministic
Currently when we reach an error state we effectively flush everything
fed to the lexer, which can put us in a state where we keep feeding
tokens into the parser at arbitrary offsets in the stream. This makes it
difficult for the lexer/tokenizer/parser to get back in sync when bad
input is made by the client.
With these changes we emit an error state/token up to the tokenizer as
soon as we reach an error state, and continue processing any data passed
in rather than bailing out. The reset token will be used to reset the
tokenizer and parser, such that they'll recover state as soon as the
lexer begins generating valid token sequences again.
We also map chr(192,193,245-255) to an error state here, since they are
invalid UTF-8 characters. QMP guest proxy/agent will use chr(255) to
force a flush/reset of previous input for reliable delivery of certain
events, so also we document that thoroughly here.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'json-lexer.h')
-rw-r--r-- | json-lexer.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/json-lexer.h b/json-lexer.h index 3b50c4634b..10bc0a7798 100644 --- a/json-lexer.h +++ b/json-lexer.h @@ -25,6 +25,7 @@ typedef enum json_token_type { JSON_STRING, JSON_ESCAPE, JSON_SKIP, + JSON_ERROR, } JSONTokenType; typedef struct JSONLexer JSONLexer; |