mirror of
https://github.com/mii443/qemu.git
synced 2025-08-22 15:15:46 +00:00
json: Support %% in JSON strings when interpolating
The previous commit makes JSON strings containing '%' awkward to express in templates: you'd have to mask the '%' with an Unicode escape \u0025. No template currently contains such JSON strings. Support the printf conversion specification %% in JSON strings as a convenience anyway, because it's trivially easy to do. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180823164025.12553-58-armbru@redhat.com>
This commit is contained in:
@ -208,10 +208,11 @@ static QString *parse_string(JSONParserContext *ctxt, JSONToken *token)
|
||||
}
|
||||
break;
|
||||
case '%':
|
||||
if (ctxt->ap) {
|
||||
if (ctxt->ap && ptr[1] != '%') {
|
||||
parse_error(ctxt, token, "can't interpolate into string");
|
||||
goto out;
|
||||
}
|
||||
ptr++;
|
||||
/* fall through */
|
||||
default:
|
||||
cp = mod_utf8_codepoint(ptr, 6, &end);
|
||||
|
Reference in New Issue
Block a user