pgbackrest.git / summary / log / commit / refs
commit 3da60f4b5ee8ed663fc5e8d8968709dbaadee1f6
Author: David Steele <david@crunchydata.com>
Date: Wed May 22 15:10:43 2019 +0000
Don't escape / when rendering JSON.
/ is escaped in the spec but the Perl renderer we use does not escape it which leads to checksum mismatches between the two sets of code.
This particular escape seems to be a more recent addition to the spec and is targeted toward embedding JSON in JavaScript.
\/ is still allowed when parsing JSON.
src/common/type/json.c | 4 ----
test/src/module/common/typeJsonTest.c | 16 ++++++++--------
test/src/module/perl/configTest.c | 2 +-
3 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/src/common/type/json.c b/src/common/type/json.c
index e72bb685a..36497c044 100644
--- a/src/common/type/json.c
+++ b/src/common/type/json.c
@@ -677,10 +677,6 @@ jsonFromStrInternal(String *json, const String *string)
strCat(json, "\\\\");
break;
- case '/':
- strCat(json, "\\/");
- break;
-
case '\n':
strCat(json, "\\n");
break;
diff --git a/test/src/module/common/typeJsonTest.c b/test/src/module/common/typeJsonTest.c
index f953e1e9e..674c16e22 100644
--- a/test/src/module/common/typeJsonTest.c
+++ b/test/src/module/common/typeJsonTest.c
@@ -137,7 +137,7 @@ testRun(void)
{
TEST_RESULT_STR(strPtr(jsonFromStr(NULL)), "null", "null string");
TEST_RESULT_STR(strPtr(jsonFromStr(strNew("simple string"))), "\"simple string\"", "simple string");
- TEST_RESULT_STR(strPtr(jsonFromStr(strNew("\"\\/\b\n\r\t\f"))), "\"\\\"\\\\\\/\\b\\n\\r\\t\\f\"", "string escapes");
+ TEST_RESULT_STR(strPtr(jsonFromStr(strNew("\"\\/\b\n\r\t\f"))), "\"\\\"\\\\/\\b\\n\\r\\t\\f\"", "string escapes");
}
// *****************************************************************************************************************************
@@ -254,7 +254,7 @@ testRun(void)
"{\"backup-info-size-delta\":1982702,\"backup-prior\":\"20161219-212741F_20161219-212803I\","
"\"backup-reference\":[\"20161219-212741F\",\"20161219-212741F_20161219-212803I\",null],"
"\"backup-timestamp-start\":1482182951,\"checksum-page-error\":[1],"
- "\"section\":{\"escape\":\"\\\"\\\\\\/\\b\\n\\r\\t\\f\",\"key1\":\"value1\",\"key2\":null,\"key3\":\"value2\"}}",
+ "\"section\":{\"escape\":\"\\\"\\\\/\\b\\n\\r\\t\\f\",\"key1\":\"value1\",\"key2\":null,\"key3\":\"value2\"}}",
" sorted json string result, no pretty print");
TEST_ASSIGN(json, jsonFromVar(keyValue, 4), "KeyValue - indent 4");
@@ -272,7 +272,7 @@ testRun(void)
" 1\n"
" ],\n"
" \"section\" : {\n"
- " \"escape\" : \"\\\"\\\\\\/\\b\\n\\r\\t\\f\",\n"
+ " \"escape\" : \"\\\"\\\\/\\b\\n\\r\\t\\f\",\n"
" \"key1\" : \"value1\",\n"
" \"key2\" : null,\n"
" \"key3\" : \"value2\"\n"
@@ -294,7 +294,7 @@ testRun(void)
"[{\"backup-info-size-delta\":1982702,\"backup-prior\":\"20161219-212741F_20161219-212803I\","
"\"backup-reference\":[\"20161219-212741F\",\"20161219-212741F_20161219-212803I\",null],"
"\"backup-timestamp-start\":1482182951,\"checksum-page-error\":[1],"
- "\"section\":{\"escape\":\"\\\"\\\\\\/\\b\\n\\r\\t\\f\",\"key1\":\"value1\",\"key2\":null,\"key3\":\"value2\"}}]",
+ "\"section\":{\"escape\":\"\\\"\\\\/\\b\\n\\r\\t\\f\",\"key1\":\"value1\",\"key2\":null,\"key3\":\"value2\"}}]",
" sorted json string result no pretty print");
Variant *keyValue2 = varDup(keyValue);
@@ -305,11 +305,11 @@ testRun(void)
"[{\"backup-info-size-delta\":1982702,\"backup-prior\":\"20161219-212741F_20161219-212803I\","
"\"backup-reference\":[\"20161219-212741F\",\"20161219-212741F_20161219-212803I\",null],"
"\"backup-timestamp-start\":1482182951,\"checksum-page-error\":[1],"
- "\"section\":{\"escape\":\"\\\"\\\\\\/\\b\\n\\r\\t\\f\",\"key1\":\"value1\",\"key2\":null,\"key3\":\"value2\"}},"
+ "\"section\":{\"escape\":\"\\\"\\\\/\\b\\n\\r\\t\\f\",\"key1\":\"value1\",\"key2\":null,\"key3\":\"value2\"}},"
"{\"backup-info-size-delta\":1982702,\"backup-prior\":\"20161219-212741F_20161219-212803I\","
"\"backup-reference\":[\"20161219-212741F\",\"20161219-212741F_20161219-212803I\",null],"
"\"backup-timestamp-start\":1482182951,\"checksum-page-error\":[1],"
- "\"section\":{\"escape\":\"\\\"\\\\\\/\\b\\n\\r\\t\\f\",\"key1\":\"value1\",\"key2\":null,\"key3\":\"value2\"}}]",
+ "\"section\":{\"escape\":\"\\\"\\\\/\\b\\n\\r\\t\\f\",\"key1\":\"value1\",\"key2\":null,\"key3\":\"value2\"}}]",
" sorted json string result no pretty print");
TEST_ASSIGN(json, jsonFromVar(varListOuter, 2), "VariantList - indent 2 - multiple elements");
@@ -328,7 +328,7 @@ testRun(void)
" 1\n"
" ],\n"
" \"section\" : {\n"
- " \"escape\" : \"\\\"\\\\\\/\\b\\n\\r\\t\\f\",\n"
+ " \"escape\" : \"\\\"\\\\/\\b\\n\\r\\t\\f\",\n"
" \"key1\" : \"value1\",\n"
" \"key2\" : null,\n"
" \"key3\" : \"value2\"\n"
@@ -347,7 +347,7 @@ testRun(void)
" 1\n"
" ],\n"
" \"section\" : {\n"
- " \"escape\" : \"\\\"\\\\\\/\\b\\n\\r\\t\\f\",\n"
+ " \"escape\" : \"\\\"\\\\/\\b\\n\\r\\t\\f\",\n"
" \"key1\" : \"value1\",\n"
" \"key2\" : null,\n"
" \"key3\" : \"value2\"\n"
diff --git a/test/src/module/perl/configTest.c b/test/src/module/perl/configTest.c
index 0e2e605e5..3b2dac09d 100644
--- a/test/src/module/perl/configTest.c
+++ b/test/src/module/perl/configTest.c
@@ -67,7 +67,7 @@ testRun(void)
"\"config\":{\"negate\":true,\"reset\":false,\"source\":\"param\",\"valid\":true},"
"\"online\":{\"negate\":true,\"reset\":false,\"source\":\"param\",\"valid\":true,\"value\":false},"
"\"pg1-host\":{\"negate\":false,\"reset\":true,\"source\":\"default\",\"valid\":true},"
- "\"pg1-path\":{\"negate\":false,\"reset\":false,\"source\":\"config\",\"valid\":true,\"value\":\"\\/path\\/db\\/pg\"},"
+ "\"pg1-path\":{\"negate\":false,\"reset\":false,\"source\":\"config\",\"valid\":true,\"value\":\"/path/db/pg\"},"
"\"protocol-timeout\":{\"negate\":false,\"reset\":false,\"source\":\"param\",\"valid\":true,\"value\":1.1},"
"\"repo1-cipher-pass\":{\"negate\":false,\"reset\":false,\"source\":\"config\",\"valid\":true,"
"\"value\":\"part1\\npart2\"},"
[parent: 664054fea941]