]> git.ipfire.org Git - thirdparty/iproute2.git/commit
json: do not escape single quotes
authorAndrea Claudi <aclaudi@redhat.com>
Thu, 3 Nov 2022 17:39:25 +0000 (18:39 +0100)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 3 Nov 2022 18:30:20 +0000 (11:30 -0700)
commit49c63bc775d610c3dfd3db0d6501ac29c519967f
tree411c8302fd7bebd78b2ddc3feb83f72b76c3d855
parent683a8b8d64b3632e5282f1fce13550c2fe70fa31
json: do not escape single quotes

ECMA-404 standard does not include single quote character among the json
escape sequences. This means single quotes does not need to be escaped.

Indeed the single quote escape produces an invalid json output:

$ ip link add "john's" type dummy
$ ip link show "john's"
9: john's: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether c6:8e:53:f6:a3:4b brd ff:ff:ff:ff:ff:ff
$ ip -j link | jq .
parse error: Invalid escape at line 1, column 765

This can be fixed removing the single quote escape in jsonw_puts.
With this patch in place:

$ ip -j link | jq .[].ifname
"lo"
"john's"

Fixes: fcc16c2287bf ("provide common json output formatter")
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
lib/json_writer.c