Skip to content

Commit

Permalink
fix(json): Add backslash to unescaped character list (facebookincubat…
Browse files Browse the repository at this point in the history
…or#12442)

Summary:

facebookincubator#12389

Fix json_parse error due to lacking switch case for backslash.

Differential Revision: D70132773
  • Loading branch information
peterenescu authored and facebook-github-bot committed Feb 25, 2025
1 parent b0d7de9 commit 2412aa4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions velox/functions/prestosql/json/JsonStringUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ int32_t getEscapedChar(std::string_view view, size_t& pos) {
case 't':
pos += 2;
return '\t';
case '\\':
pos += 2;
return '\\';

default:
// Presto java ignores bad escape sequences.
Expand Down
1 change: 1 addition & 0 deletions velox/functions/prestosql/tests/JsonFunctionsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ TEST_F(JsonFunctionsTest, jsonParse) {
EXPECT_EQ(jsonParse(R"(["k1", "v1"])"), R"(["k1","v1"])");
testJsonParse(R"({ "abc" : "\/"})", R"({"abc":"/"})");
testJsonParse(R"({ "abc" : "\\/"})", R"({"abc":"\\/"})");
testJsonParse("{\"\\\\\":null, \"\\\\\":null}", R"({"\\":null,"\\":null})");
testJsonParse(R"({ "abc" : [1, 2, 3, 4 ]})", R"({"abc":[1,2,3,4]})");
// Test out with unicodes and empty keys.
testJsonParse(
Expand Down

0 comments on commit 2412aa4

Please sign in to comment.