public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
* [PATCH iproute2] json: do not escape single quotes
@ 2022-11-03 17:39 Andrea Claudi
  2022-11-03 18:40 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Andrea Claudi @ 2022-11-03 17:39 UTC (permalink / raw)
  To: netdev; +Cc: stephen, dsahern

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 | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/lib/json_writer.c b/lib/json_writer.c
index 88c5eb88..2f3936c2 100644
--- a/lib/json_writer.c
+++ b/lib/json_writer.c
@@ -80,9 +80,6 @@ static void jsonw_puts(json_writer_t *self, const char *str)
 		case '"':
 			fputs("\\\"", self->out);
 			break;
-		case '\'':
-			fputs("\\\'", self->out);
-			break;
 		default:
 			putc(*str, self->out);
 		}
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH iproute2] json: do not escape single quotes
  2022-11-03 17:39 [PATCH iproute2] json: do not escape single quotes Andrea Claudi
@ 2022-11-03 18:40 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-11-03 18:40 UTC (permalink / raw)
  To: Andrea Claudi; +Cc: netdev, stephen, dsahern

Hello:

This patch was applied to iproute2/iproute2.git (main)
by Stephen Hemminger <stephen@networkplumber•org>:

On Thu,  3 Nov 2022 18:39:25 +0100 you wrote:
> 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
> 
> [...]

Here is the summary with links:
  - [iproute2] json: do not escape single quotes
    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=49c63bc775d6

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-03 18:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-03 17:39 [PATCH iproute2] json: do not escape single quotes Andrea Claudi
2022-11-03 18:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox