* [PATCH] tools: bpftool: remove invalid \' json escape
@ 2023-02-27 15:08 Luis Gerhorst
2023-02-27 15:40 ` Quentin Monnet
2023-02-27 19:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Luis Gerhorst @ 2023-02-27 15:08 UTC (permalink / raw)
To: Quentin Monnet, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
bpf, linux-kernel
Cc: Luis Gerhorst
RFC8259 ("The JavaScript Object Notation (JSON) Data Interchange
Format") only specifies \", \\, \/, \b, \f, \n, \r, and \r as valid
two-character escape sequences. This does not include \', which is not
required in JSON because it exclusively uses double quotes as string
separators.
Solidus (/) may be escaped, but does not have to. Only reverse
solidus (\), double quotes ("), and the control characters have to be
escaped. Therefore, with this fix, bpftool correctly supports all valid
two-character escape sequences (but still does not support characters
that require multi-character escape sequences).
Witout this fix, attempting to load a JSON file generated by bpftool
using Python 3.10.6's default json.load() may fail with the error
"Invalid \escape" if the file contains the invalid escaped single
quote (\').
Signed-off-by: Luis Gerhorst <gerhorst@cs.fau.de>
---
tools/bpf/bpftool/json_writer.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/tools/bpf/bpftool/json_writer.c b/tools/bpf/bpftool/json_writer.c
index 7fea83bedf48..bca5dd0a59e3 100644
--- a/tools/bpf/bpftool/json_writer.c
+++ b/tools/bpf/bpftool/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.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tools: bpftool: remove invalid \' json escape
2023-02-27 15:08 [PATCH] tools: bpftool: remove invalid \' json escape Luis Gerhorst
@ 2023-02-27 15:40 ` Quentin Monnet
2023-02-27 19:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Quentin Monnet @ 2023-02-27 15:40 UTC (permalink / raw)
To: Luis Gerhorst, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Martin KaFai Lau, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
bpf, linux-kernel
2023-02-27 16:08 UTC+0100 ~ Luis Gerhorst <gerhorst@cs.fau.de>
> RFC8259 ("The JavaScript Object Notation (JSON) Data Interchange
> Format") only specifies \", \\, \/, \b, \f, \n, \r, and \r as valid
> two-character escape sequences. This does not include \', which is not
> required in JSON because it exclusively uses double quotes as string
> separators.
>
> Solidus (/) may be escaped, but does not have to. Only reverse
> solidus (\), double quotes ("), and the control characters have to be
> escaped. Therefore, with this fix, bpftool correctly supports all valid
> two-character escape sequences (but still does not support characters
> that require multi-character escape sequences).
>
> Witout this fix, attempting to load a JSON file generated by bpftool
> using Python 3.10.6's default json.load() may fail with the error
> "Invalid \escape" if the file contains the invalid escaped single
> quote (\').
>
> Signed-off-by: Luis Gerhorst <gerhorst@cs.fau.de>
Fixes: b66e907cfee2 ("tools: bpftool: copy JSON writer from iproute2
repository")
I see this escape was similarly removed from iproute2's version of the
file [0]. Thanks!
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
[0]
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/lib/json_writer.c?id=49c63bc775d610c3dfd3db0d6501ac29c519967f
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tools: bpftool: remove invalid \' json escape
2023-02-27 15:08 [PATCH] tools: bpftool: remove invalid \' json escape Luis Gerhorst
2023-02-27 15:40 ` Quentin Monnet
@ 2023-02-27 19:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-02-27 19:30 UTC (permalink / raw)
To: Luis Gerhorst
Cc: quentin, ast, daniel, andrii, martin.lau, song, yhs,
john.fastabend, kpsingh, sdf, haoluo, jolsa, bpf, linux-kernel
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Mon, 27 Feb 2023 16:08:54 +0100 you wrote:
> RFC8259 ("The JavaScript Object Notation (JSON) Data Interchange
> Format") only specifies \", \\, \/, \b, \f, \n, \r, and \r as valid
> two-character escape sequences. This does not include \', which is not
> required in JSON because it exclusively uses double quotes as string
> separators.
>
> Solidus (/) may be escaped, but does not have to. Only reverse
> solidus (\), double quotes ("), and the control characters have to be
> escaped. Therefore, with this fix, bpftool correctly supports all valid
> two-character escape sequences (but still does not support characters
> that require multi-character escape sequences).
>
> [...]
Here is the summary with links:
- tools: bpftool: remove invalid \' json escape
https://git.kernel.org/bpf/bpf-next/c/c679bbd611c0
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] 3+ messages in thread
end of thread, other threads:[~2023-02-27 19:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-27 15:08 [PATCH] tools: bpftool: remove invalid \' json escape Luis Gerhorst
2023-02-27 15:40 ` Quentin Monnet
2023-02-27 19:30 ` 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