Skip to content
Snippets Groups Projects
Commit 55ce1101 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

fixed a JSON bug with handling backspaces

This was fixed in upstream and the upstream tests caught this :-)
parent 040571db
No related branches found
No related tags found
No related merge requests found
......@@ -569,17 +569,17 @@ class JSON {
}
} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) &&
in_array($top['what'], array(JSON_SLICE, JSON_IN_ARR, JSON_IN_OBJ))) {
} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != JSON_IN_STR)) {
// found a quote, and we are not inside a string
array_push($stk, array('what' => JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
//print("Found start of string at {$c}\n");
} elseif (($chrs{$c} == $top['delim']) &&
($top['what'] == JSON_IN_STR) &&
(($chrs{$c - 1} != "\\") ||
($chrs{$c - 1} == "\\" && $chrs{$c - 2} == "\\"))) {
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
// found a quote, we're in a string, and it's not escaped
// we know that it's not escaped becase there is _not_ an
// odd number of backslashes at the end of the string so far
array_pop($stk);
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment