Paolo Bonzini <pbonzini@xxxxxxxxxx> writes: > On 23/02/21 10:06, Markus Armbruster wrote: >>> Markus, did you rebuild the qtests after disabling single-quoted >>> strings? "make check-qtest-x86_64" would have rebuilt them, but I'm >>> confused by the results. >> I ran "make check" and looked at the failures: >> Still confused? > > Yes. What's the patch that you used to disable the single quotes, and > why didn't the patched parser choke on > > response = qmp("{ 'execute': 'qom-get', 'arguments': { 'path': %s, " > "'property': 'temperature' } }", id); > > ? My bad! I neglected to mention that I tied "disable single-quoted strings" to "interpolation is off" for my experiment. This is a lazy, half-assed approximation of "internal interface". Here's the experimental patch. commit 57138b9d4188dd8ce1814237fe53f7131bbb3f45 Author: Markus Armbruster <armbru@xxxxxxxxxx> Date: Mon Feb 22 17:04:10 2021 +0100 qobject: Tie single quote extension to interpolation WIP This makes several tests fail or hang. Some are hacked up. diff --git a/qobject/json-parser.c b/qobject/json-parser.c index 008b326fb8..c1ddc65d96 100644 --- a/qobject/json-parser.c +++ b/qobject/json-parser.c @@ -150,9 +150,6 @@ static QString *parse_string(JSONParserContext *ctxt, JSONToken *token) case '"': g_string_append_c(str, '"'); break; - case '\'': - g_string_append_c(str, '\''); - break; case '\\': g_string_append_c(str, '\\'); break; @@ -201,6 +198,12 @@ static QString *parse_string(JSONParserContext *ctxt, JSONToken *token) } g_string_append(str, utf8_buf); break; + case '\'': + if (ctxt->ap) { + g_string_append_c(str, '\''); + break; + } + /* fall through */ default: parse_error(ctxt, token, "invalid escape sequence in string"); goto out; diff --git a/qobject/json-streamer.c b/qobject/json-streamer.c index b93d97b995..3d4d3b484e 100644 --- a/qobject/json-streamer.c +++ b/qobject/json-streamer.c @@ -49,6 +49,11 @@ void json_message_process_token(JSONLexer *lexer, GString *input, case JSON_RSQUARE: parser->bracket_count--; break; + case JSON_STRING: + if (input->str[0] == '\"' || parser->ap) { + break; + } + /* fall through */ case JSON_ERROR: error_setg(&err, "JSON parse error, stray '%s'", input->str); goto out_emit;