You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2026-10-23 21:28:56 +03:00
Accept hex digits in JSON \u escapes when skipping.
jsonReadSkipStr() required four decimal digits after \u, so a valid escape with hex digits such as \u003c failed validation even though jsonReadStr() decodes it. Accept hex digits so skipping agrees with reading. pgBackRest does not write \u escapes, so this only affects JSON from other sources. jsonReadStr() still decodes only \u00XX, as a single byte.
This commit is contained in:
@@ -836,12 +836,12 @@ jsonReadSkipStr(JsonRead *const this)
|
||||
{
|
||||
this->json++;
|
||||
|
||||
// Expect four digits
|
||||
// Expect four hex digits
|
||||
unsigned int digitIdx = 0;
|
||||
|
||||
for (; digitIdx < 4; digitIdx++)
|
||||
{
|
||||
if (!isdigit(this->json[digitIdx]))
|
||||
if (!isxdigit((unsigned char)this->json[digitIdx]))
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -245,6 +245,7 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_VOID(jsonValidate(json), "valid");
|
||||
TEST_RESULT_VOID(jsonValidate(STRDEF("[\"\\u0041\",\"\\u1234\"]")), "valid escapes before end of string");
|
||||
TEST_RESULT_VOID(jsonValidate(STRDEF("[\"\\u003c\",\"\\uFFFF\"]")), "valid hex escapes");
|
||||
TEST_ERROR(jsonValidate(STRDEF("\"\\u0041")), JsonFormatError, "expected '\"' but found null delimiter");
|
||||
TEST_ERROR(jsonValidate(STRDEF("\"\\u000")), JsonFormatError, "unable to decode at: \\u000");
|
||||
TEST_ERROR(jsonValidate(STRDEF("\"")), JsonFormatError, "expected '\"' but found null delimiter");
|
||||
|
||||
Reference in New Issue
Block a user