You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by mg...@apache.org on 2024/06/07 22:04:27 UTC
(avro) branch main updated: [C++] Do not escape solidus in JSON output (#2929)
This is an automated email from the ASF dual-hosted git repository.
mgrigorov pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/main by this push:
new 23b0e9625 [C++] Do not escape solidus in JSON output (#2929)
23b0e9625 is described below
commit 23b0e9625591c90ec46c154bc870cf0f06e09c0a
Author: Gerrit Birkeland <ge...@gerritbirkeland.com>
AuthorDate: Fri Jun 7 16:04:21 2024 -0600
[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 4e3b2c115..4e15470f6 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 f65839058..afaa20f1a 100644
--- a/lang/c++/test/JsonTests.cc
+++ b/lang/c++/test/JsonTests.cc
@@ -65,7 +65,9 @@ TestData<const char *> 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")"},