Index: CKEditor/trunk/CHANGES.html
===================================================================
--- CKEditor/trunk/CHANGES.html (revision 6592)
+++ CKEditor/trunk/CHANGES.html (revision 6593)
@@ -89,4 +89,5 @@
#7180 : [IE9] Using Kama skin and RTL layout, dialog buttons were not being displayed correctly.
#7182 : [IE9] Using Office2003/v2 skin and RTL layout, dialog shadows were corrupted.
+ #6913 : Invalid escape sequence (\b) used in PHP integration.
Updated the following language files:
- #7124 : Czech;
Index: CKEditor/trunk/ckeditor_php4.php
===================================================================
--- CKEditor/trunk/ckeditor_php4.php (revision 6592)
+++ CKEditor/trunk/ckeditor_php4.php (revision 6593)
@@ -532,5 +532,4 @@
/**
* This little function provides a basic JSON support.
- * http://php.net/manual/en/function.json-encode.php
* \private
*
@@ -543,59 +542,30 @@
return 'null';
}
- if ($val === false) {
- return 'false';
- }
- if ($val === true) {
- return 'true';
- }
- if (is_scalar($val))
- {
- if (is_float($val))
- {
- // Always use "." for floats.
- $val = str_replace(",", ".", strval($val));
- }
-
- // Use @@ to not use quotes when outputting string value
- if (strpos($val, '@@') === 0) {
- return substr($val, 2);
- }
- else {
- // All scalars are converted to strings to avoid indeterminism.
- // PHP's "1" and 1 are equal for all PHP operators, but
- // JS's "1" and 1 are not. So if we pass "1" or 1 from the PHP backend,
- // we should get the same result in the JS frontend (string).
- // Character replacements for JSON.
- static $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'),
- array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));
-
- $val = str_replace($jsonReplaces[0], $jsonReplaces[1], $val);
- if (strtoupper(substr($val, 0, 9)) == 'CKEDITOR.') {
- return $val;
- }
-
- return '"' . $val . '"';
- }
- }
- $isList = true;
- for ($i = 0, reset($val); $i < count($val); $i++, next($val))
- {
- if (key($val) !== $i)
- {
- $isList = false;
- break;
- }
- }
- $result = array();
- if ($isList)
- {
- foreach ($val as $v) $result[] = $this->jsEncode($v);
- return '[ ' . join(', ', $result) . ' ]';
- }
- else
- {
- foreach ($val as $k => $v) $result[] = $this->jsEncode($k).': '.$this->jsEncode($v);
- return '{ ' . join(', ', $result) . ' }';
- }
+ if (is_bool($val)) {
+ return $val ? 'true' : 'false';
+ }
+ if (is_int($val)) {
+ return $val;
+ }
+ if (is_float($val)) {
+ return str_replace(',', '.', $val);
+ }
+ if (is_array($val) || is_object($val)) {
+ if (is_array($val) && (array_keys($val) === range(0,count($val)-1))) {
+ return '[' . implode(',', array_map(array($this, 'jsEncode'), $val)) . ']';
+ }
+ $temp = array();
+ foreach ($val as $k => $v){
+ $temp[] = $this->jsEncode("{$k}") . ':' . $this->jsEncode($v);
+ }
+ return '{' . implode(',', $temp) . '}';
+ }
+ // String otherwise
+ if (strpos($val, '@@') === 0)
+ return substr($val, 2);
+ if (strtoupper(substr($val, 0, 9)) == 'CKEDITOR.')
+ return $val;
+
+ return '"' . str_replace(array("\\", "/", "\n", "\t", "\r", "\x08", "\x0c", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'), $val) . '"';
}
}
Index: CKEditor/trunk/ckeditor_php5.php
===================================================================
--- CKEditor/trunk/ckeditor_php5.php (revision 6592)
+++ CKEditor/trunk/ckeditor_php5.php (revision 6593)
@@ -523,5 +523,4 @@
/**
* This little function provides a basic JSON support.
- * http://php.net/manual/en/function.json-encode.php
*
* @param mixed $val
@@ -533,59 +532,30 @@
return 'null';
}
- if ($val === false) {
- return 'false';
- }
- if ($val === true) {
- return 'true';
- }
- if (is_scalar($val))
- {
- if (is_float($val))
- {
- // Always use "." for floats.
- $val = str_replace(",", ".", strval($val));
- }
-
- // Use @@ to not use quotes when outputting string value
- if (strpos($val, '@@') === 0) {
- return substr($val, 2);
- }
- else {
- // All scalars are converted to strings to avoid indeterminism.
- // PHP's "1" and 1 are equal for all PHP operators, but
- // JS's "1" and 1 are not. So if we pass "1" or 1 from the PHP backend,
- // we should get the same result in the JS frontend (string).
- // Character replacements for JSON.
- static $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'),
- array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));
-
- $val = str_replace($jsonReplaces[0], $jsonReplaces[1], $val);
- if (strtoupper(substr($val, 0, 9)) == 'CKEDITOR.') {
- return $val;
- }
-
- return '"' . $val . '"';
- }
- }
- $isList = true;
- for ($i = 0, reset($val); $i < count($val); $i++, next($val))
- {
- if (key($val) !== $i)
- {
- $isList = false;
- break;
- }
- }
- $result = array();
- if ($isList)
- {
- foreach ($val as $v) $result[] = $this->jsEncode($v);
- return '[ ' . join(', ', $result) . ' ]';
- }
- else
- {
- foreach ($val as $k => $v) $result[] = $this->jsEncode($k).': '.$this->jsEncode($v);
- return '{ ' . join(', ', $result) . ' }';
- }
+ if (is_bool($val)) {
+ return $val ? 'true' : 'false';
+ }
+ if (is_int($val)) {
+ return $val;
+ }
+ if (is_float($val)) {
+ return str_replace(',', '.', $val);
+ }
+ if (is_array($val) || is_object($val)) {
+ if (is_array($val) && (array_keys($val) === range(0,count($val)-1))) {
+ return '[' . implode(',', array_map(array($this, 'jsEncode'), $val)) . ']';
+ }
+ $temp = array();
+ foreach ($val as $k => $v){
+ $temp[] = $this->jsEncode("{$k}") . ':' . $this->jsEncode($v);
+ }
+ return '{' . implode(',', $temp) . '}';
+ }
+ // String otherwise
+ if (strpos($val, '@@') === 0)
+ return substr($val, 2);
+ if (strtoupper(substr($val, 0, 9)) == 'CKEDITOR.')
+ return $val;
+
+ return '"' . str_replace(array("\\", "/", "\n", "\t", "\r", "\x08", "\x0c", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'), $val) . '"';
}
}