From: Christophe Fergeau <cfergeau@redhat.com>
To: qemu-devel@nongnu.org
Cc: Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] json: Fix % handling when not interpolating
Date: Wed, 2 Jan 2019 19:01:58 +0100 [thread overview]
Message-ID: <20190102180158.GA6015@natto.ory.fergeau.eu> (raw)
In-Reply-To: <20190102140535.11512-1-cfergeau@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2172 bytes --]
Adding Markus to cc: list, I forgot to do it when sending the patch.
Christophe
On Wed, Jan 02, 2019 at 03:05:35PM +0100, Christophe Fergeau wrote:
> commit 8bca4613 added support for %% in json strings when interpolating,
> but in doing so, this broke handling of % when not interpolating as the
> '%' is skipped in both cases.
> This commit ensures we only try to handle %% when interpolating.
>
> Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
> ---
> qobject/json-parser.c | 10 ++++++----
> tests/check-qjson.c | 5 +++++
> 2 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/qobject/json-parser.c b/qobject/json-parser.c
> index 7a7ae9e8d1..d8eb210c0c 100644
> --- a/qobject/json-parser.c
> +++ b/qobject/json-parser.c
> @@ -208,11 +208,13 @@ static QString *parse_string(JSONParserContext *ctxt, JSONToken *token)
> }
> break;
> case '%':
> - if (ctxt->ap && ptr[1] != '%') {
> - parse_error(ctxt, token, "can't interpolate into string");
> - goto out;
> + if (ctxt->ap) {
> + if (ptr[1] != '%') {
> + parse_error(ctxt, token, "can't interpolate into string");
> + goto out;
> + }
> + ptr++;
> }
> - ptr++;
> /* fall through */
> default:
> cp = mod_utf8_codepoint(ptr, 6, &end);
> diff --git a/tests/check-qjson.c b/tests/check-qjson.c
> index d876a7a96e..fa2afccb0a 100644
> --- a/tests/check-qjson.c
> +++ b/tests/check-qjson.c
> @@ -175,6 +175,11 @@ static void utf8_string(void)
> "\xCE\xBA\xE1\xBD\xB9\xCF\x83\xCE\xBC\xCE\xB5",
> "\xCE\xBA\xE1\xBD\xB9\xCF\x83\xCE\xBC\xCE\xB5",
> "\\u03BA\\u1F79\\u03C3\\u03BC\\u03B5",
> + },
> + /* '%' character when not interpolating */
> + {
> + "100%",
> + "100%",
> },
> /* 2 Boundary condition test cases */
> /* 2.1 First possible sequence of a certain length */
> --
> 2.20.1
>
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2019-01-02 18:02 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-02 14:05 [Qemu-devel] [PATCH] json: Fix % handling when not interpolating Christophe Fergeau
2019-01-02 18:01 ` Christophe Fergeau [this message]
2019-01-02 22:08 ` Eric Blake
2019-01-07 15:47 ` Markus Armbruster
2019-01-07 16:26 ` Eric Blake
2019-01-07 16:36 ` Christophe Fergeau
2019-01-08 10:36 ` Markus Armbruster
2019-01-09 13:06 ` Max Reitz
2019-01-09 14:32 ` Markus Armbruster
2019-01-09 14:41 ` Max Reitz
2019-01-09 16:20 ` Markus Armbruster
2019-01-09 16:29 ` Max Reitz
2019-01-09 14:49 ` Daniel P. Berrangé
2019-01-09 15:02 ` Max Reitz
2019-01-09 16:55 ` Daniel P. Berrangé
2019-01-10 9:30 ` Markus Armbruster
2019-01-22 11:18 ` Richard W.M. Jones
2019-01-24 9:35 ` Markus Armbruster
2019-01-24 12:39 ` Christophe Fergeau
2019-01-24 18:13 ` Eric Blake
2019-01-24 18:29 ` Markus Armbruster
2019-01-24 19:55 ` Eric Blake
2019-01-22 11:21 ` Richard W.M. Jones
2019-01-24 14:37 ` Markus Armbruster
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=20190102180158.GA6015@natto.ory.fergeau.eu \
--to=cfergeau@redhat.com \
--cc=armbru@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).