diff options
author | Andreas Gohr <andi@splitbrain.org> | 2012-05-03 00:34:24 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2012-05-03 00:34:24 +0200 |
commit | 55ce110126c81c7f7c821183fab3018cacc40016 (patch) | |
tree | bc5037806acebc32f93ace28b45188aee852d725 | |
parent | 040571dbb13c148147a105a8c0857057c358093c (diff) | |
download | rpg-55ce110126c81c7f7c821183fab3018cacc40016.tar.gz rpg-55ce110126c81c7f7c821183fab3018cacc40016.tar.bz2 |
fixed a JSON bug with handling backspaces
This was fixed in upstream and the upstream tests caught this :-)
-rw-r--r-- | inc/JSON.php | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/inc/JSON.php b/inc/JSON.php index 012697eb3..7f89005ff 100644 --- a/inc/JSON.php +++ b/inc/JSON.php @@ -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"); |