From: Markus Armbruster <armbru@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: libvir-list@redhat.com,
"Peter Maydell" <peter.maydell@linaro.org>,
"John Snow" <jsnow@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: A brief look at deprecating our JSON extensions over RFC 8259
Date: Tue, 23 Feb 2021 13:34:56 +0100 [thread overview]
Message-ID: <87wnuzc68f.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <f883798f-8054-61a3-a1ec-a1e80b6c2f4b@redhat.com> (Paolo Bonzini's message of "Tue, 23 Feb 2021 11:59:20 +0100")
Paolo Bonzini <pbonzini@redhat.com> 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@redhat.com>
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;
next prev parent reply other threads:[~2021-02-23 12:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-22 14:57 A brief look at deprecating our JSON extensions over RFC 8259 Markus Armbruster
2021-02-22 15:10 ` Peter Krempa
2021-02-22 15:24 ` Daniel P. Berrangé
2021-02-22 15:43 ` Liviu Ionescu
2021-02-22 17:47 ` Paolo Bonzini
2021-02-22 17:54 ` Daniel P. Berrangé
2021-02-22 18:06 ` Paolo Bonzini
2021-02-23 9:31 ` Markus Armbruster
2021-02-23 9:37 ` Markus Armbruster
2021-02-23 11:03 ` Peter Maydell
2021-02-23 12:43 ` Markus Armbruster
2021-02-23 9:06 ` Markus Armbruster
2021-02-23 10:59 ` Paolo Bonzini
2021-02-23 12:34 ` Markus Armbruster [this message]
2021-02-22 17:42 ` Paolo Bonzini
2021-02-22 18:01 ` Daniel P. Berrangé
2021-02-22 18:22 ` Peter Krempa
2021-02-22 18:25 ` Peter Krempa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wnuzc68f.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=jsnow@redhat.com \
--cc=libvir-list@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.