Skip to content

Commit a056840

Browse files
legendecasdanielleadams
authored andcommitted
src: fix json utils escapes for U+000B
PR-URL: #43206 Fixes: #43193 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 71802c3 commit a056840

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/json_utils.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ namespace node {
55
std::string EscapeJsonChars(const std::string& str) {
66
const std::string control_symbols[0x20] = {
77
"\\u0000", "\\u0001", "\\u0002", "\\u0003", "\\u0004", "\\u0005",
8-
"\\u0006", "\\u0007", "\\b", "\\t", "\\n", "\\v", "\\f", "\\r",
9-
"\\u000e", "\\u000f", "\\u0010", "\\u0011", "\\u0012", "\\u0013",
10-
"\\u0014", "\\u0015", "\\u0016", "\\u0017", "\\u0018", "\\u0019",
11-
"\\u001a", "\\u001b", "\\u001c", "\\u001d", "\\u001e", "\\u001f"
12-
};
8+
"\\u0006", "\\u0007", "\\b", "\\t", "\\n", "\\u000b",
9+
"\\f", "\\r", "\\u000e", "\\u000f", "\\u0010", "\\u0011",
10+
"\\u0012", "\\u0013", "\\u0014", "\\u0015", "\\u0016", "\\u0017",
11+
"\\u0018", "\\u0019", "\\u001a", "\\u001b", "\\u001c", "\\u001d",
12+
"\\u001e", "\\u001f"};
1313

1414
std::string ret;
1515
size_t last_pos = 0;

test/cctest/test_json_utils.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ TEST(JSONUtilsTest, EscapeJsonChars) {
1212

1313
const std::string expected[0x20] = {
1414
"\\u0000", "\\u0001", "\\u0002", "\\u0003", "\\u0004", "\\u0005",
15-
"\\u0006", "\\u0007", "\\b", "\\t", "\\n", "\\v", "\\f", "\\r",
16-
"\\u000e", "\\u000f", "\\u0010", "\\u0011", "\\u0012", "\\u0013",
17-
"\\u0014", "\\u0015", "\\u0016", "\\u0017", "\\u0018", "\\u0019",
18-
"\\u001a", "\\u001b", "\\u001c", "\\u001d", "\\u001e", "\\u001f"
19-
};
15+
"\\u0006", "\\u0007", "\\b", "\\t", "\\n", "\\u000b",
16+
"\\f", "\\r", "\\u000e", "\\u000f", "\\u0010", "\\u0011",
17+
"\\u0012", "\\u0013", "\\u0014", "\\u0015", "\\u0016", "\\u0017",
18+
"\\u0018", "\\u0019", "\\u001a", "\\u001b", "\\u001c", "\\u001d",
19+
"\\u001e", "\\u001f"};
2020
for (int i = 0; i < 0x20; ++i) {
2121
char symbols[1] = { static_cast<char>(i) };
2222
std::string input(symbols, 1);

0 commit comments

Comments
 (0)