From: Emanuele Torre Date: Sun, 9 Jul 2023 14:45:39 +0000 (+0200) Subject: tool_writeout_json: fix encoding of control characters X-Git-Tag: curl-8_2_0~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8484ad09da10674e62dcd8acc31ff42d67938b67;p=thirdparty%2Fcurl.git tool_writeout_json: fix encoding of control characters Control characters without a special escape sequence e.g. %00 or %06 were being encoded as "u0006" instead of "\u0006". Ref: https://github.com/curl/trurl/pull/214#discussion_r1257487858 Closes #11414 --- diff --git a/src/tool_writeout_json.c b/src/tool_writeout_json.c index ec9c640b5e..0e4623fe86 100644 --- a/src/tool_writeout_json.c +++ b/src/tool_writeout_json.c @@ -62,7 +62,7 @@ void jsonWriteString(FILE *stream, const char *in, bool lowercase) break; default: if(*i < 32) { - fprintf(stream, "u%04x", *i); + fprintf(stream, "\\u%04x", *i); } else { char out = *i;