From 23b0e9625591c90ec46c154bc870cf0f06e09c0a Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Fri, 7 Jun 2024 16:04:21 -0600 Subject: [PATCH] [C++] Do not escape solidus in JSON output (#2929) --- lang/c++/impl/json/JsonIO.hh | 1 - lang/c++/test/JsonTests.cc | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lang/c++/impl/json/JsonIO.hh b/lang/c++/impl/json/JsonIO.hh index 4e3b2c115c8..4e15470f6af 100644 --- a/lang/c++/impl/json/JsonIO.hh +++ b/lang/c++/impl/json/JsonIO.hh @@ -321,7 +321,6 @@ class AVRO_DECL JsonGenerator { switch (*p) { case '\\': case '"': - case '/': escape(*p, b, p); break; case '\b': diff --git a/lang/c++/test/JsonTests.cc b/lang/c++/test/JsonTests.cc index f65839058d2..afaa20f1ac4 100644 --- a/lang/c++/test/JsonTests.cc +++ b/lang/c++/test/JsonTests.cc @@ -65,7 +65,9 @@ TestData stringData[] = { {R"("\U000a")", EntityType::String, "\n", R"("\n")"}, {R"("\u000a")", EntityType::String, "\n", R"("\n")"}, {R"("\"")", EntityType::String, "\"", R"("\"")"}, - {R"("\/")", EntityType::String, "/", R"("\/")"}, + // While a solidus may be escaped according to the JSON standard, it need not be escaped. + {R"("/\/")", EntityType::String, "//", R"("//")"}, + {R"("\b\f\n\r\t")", EntityType::String, "\b\f\n\r\t", R"("\b\f\n\r\t")"}, {R"("\u20ac")", EntityType::String, "\xe2\x82\xac", R"("\u20ac")"}, {R"("\u03c0")", EntityType::String, "\xcf\x80", R"("\u03c0")"}, {R"("hello\n")", EntityType::String, "hello\n", R"("hello\n")"},