]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_writeout_json: fix encoding of control characters
authorEmanuele Torre <torreemanuele6@gmail.com>
Sun, 9 Jul 2023 14:45:39 +0000 (16:45 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 9 Jul 2023 16:57:01 +0000 (18:57 +0200)
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

src/tool_writeout_json.c

index ec9c640b5ed73d39acf796149bf4c14ddb1dc438..0e4623fe8694952638555dbd5e368b0417e556ea 100644 (file)
@@ -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;