[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] json: Fix % handling when not interpolating
From: |
Christophe Fergeau |
Subject: |
[Qemu-devel] [PATCH] json: Fix % handling when not interpolating |
Date: |
Wed, 2 Jan 2019 15:05:35 +0100 |
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 <address@hidden>
---
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
- [Qemu-devel] [PATCH] json: Fix % handling when not interpolating,
Christophe Fergeau <=
- Re: [Qemu-devel] [PATCH] json: Fix % handling when not interpolating, Christophe Fergeau, 2019/01/02
- Re: [Qemu-devel] [PATCH] json: Fix % handling when not interpolating, Eric Blake, 2019/01/02
- Re: [Qemu-devel] [PATCH] json: Fix % handling when not interpolating, Markus Armbruster, 2019/01/07
- Re: [Qemu-devel] [PATCH] json: Fix % handling when not interpolating, Eric Blake, 2019/01/07
- Re: [Qemu-devel] [PATCH] json: Fix % handling when not interpolating, Christophe Fergeau, 2019/01/07
- Re: [Qemu-devel] [PATCH] json: Fix % handling when not interpolating, Markus Armbruster, 2019/01/08
- Re: [Qemu-devel] [PATCH] json: Fix % handling when not interpolating, Max Reitz, 2019/01/09
- Re: [Qemu-devel] [PATCH] json: Fix % handling when not interpolating, Markus Armbruster, 2019/01/09
- Re: [Qemu-devel] [PATCH] json: Fix % handling when not interpolating, Max Reitz, 2019/01/09
- Re: [Qemu-devel] [PATCH] json: Fix % handling when not interpolating, Markus Armbruster, 2019/01/09