Let non-strict JSON Pointer syntax allow "~t"

This commit is contained in:
Nigel Tao committed 2020-11-15 20:56:04 +11:00
1 parent 42d569f5db
commit 904004e79a
6 files changed
+67 -44

No files matched your search

+13 -9
View File
@@ -100,7 +100,7 @@ namespace {
std::pair<std::string, size_t> //
DecodeJson_SplitJsonPointer(std::string& s,
size_t i,
bool allow_tilde_r_tilde_n) {
bool allow_tilde_n_tilde_r_tilde_t) {
std::string fragment;
while (i < s.size()) {
char c = s[i];
@@ -124,13 +124,17 @@ DecodeJson_SplitJsonPointer(std::string& s,
fragment.push_back('/');
i++;
continue;
} else if (allow_tilde_r_tilde_n) {
if (c == 'r') {
} else if (allow_tilde_n_tilde_r_tilde_t) {
if (c == 'n') {
fragment.push_back('\n');
i++;
continue;
} else if (c == 'r') {
fragment.push_back('\r');
i++;
continue;
} else if (c == 'n') {
fragment.push_back('\n');
} else if (c == 't') {
fragment.push_back('\t');
i++;
continue;
}
@@ -353,12 +357,12 @@ DecodeJson(DecodeJsonCallbacks& callbacks,
ret_error_message = "wuffs_aux::DecodeJson: out of memory";
goto done;
}
bool allow_tilde_r_tilde_n = false;
bool allow_tilde_n_tilde_r_tilde_t = false;
for (size_t i = 0; i < quirks.len; i++) {
dec->set_quirk_enabled(quirks.ptr[i], true);
if (quirks.ptr[i] ==
WUFFS_JSON__QUIRK_JSON_POINTER_ALLOW_TILDE_R_TILDE_N) {
allow_tilde_r_tilde_n = true;
WUFFS_JSON__QUIRK_JSON_POINTER_ALLOW_TILDE_N_TILDE_R_TILDE_T) {
allow_tilde_n_tilde_r_tilde_t = true;
}
}
@@ -380,7 +384,7 @@ DecodeJson(DecodeJsonCallbacks& callbacks,
goto done;
}
std::pair<std::string, size_t> split = DecodeJson_SplitJsonPointer(
json_pointer, i + 1, allow_tilde_r_tilde_n);
json_pointer, i + 1, allow_tilde_n_tilde_r_tilde_t);
i = std::move(split.second);
if (i == 0) {
ret_error_message = DecodeJson_BadJsonPointer;