summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inc/JSON.php8
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");