summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
Diffstat (limited to 'program/include')
-rw-r--r--program/include/rcube_json_output.php6
-rw-r--r--program/include/rcube_shared.inc17
-rwxr-xr-xprogram/include/rcube_template.php4
3 files changed, 21 insertions, 6 deletions
diff --git a/program/include/rcube_json_output.php b/program/include/rcube_json_output.php
index cb8a7dbf4..080bab631 100644
--- a/program/include/rcube_json_output.php
+++ b/program/include/rcube_json_output.php
@@ -239,7 +239,7 @@ class rcube_json_output
if (!empty($this->callbacks))
$response['callbacks'] = $this->callbacks;
- echo json_encode($response);
+ echo json_serialize($response);
}
@@ -251,11 +251,11 @@ class rcube_json_output
private function get_js_commands()
{
$out = '';
-
+
foreach ($this->commands as $i => $args) {
$method = array_shift($args);
foreach ($args as $i => $arg) {
- $args[$i] = json_encode($arg);
+ $args[$i] = json_serialize($arg);
}
$out .= sprintf(
diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc
index f4c6f7126..547174b8a 100644
--- a/program/include/rcube_shared.inc
+++ b/program/include/rcube_shared.inc
@@ -510,7 +510,7 @@ function rc_utf8_clean($input)
if (!is_string($input) || $input == '')
return $input;
-
+
// iconv/mbstring are much faster (especially with long strings)
if (function_exists('mb_convert_encoding') && ($res = mb_convert_encoding($input, 'UTF8', 'UTF8')))
return $res;
@@ -563,6 +563,21 @@ function rc_utf8_clean($input)
return $out;
}
+
+/**
+ * Convert a variable into a javascript object notation
+ *
+ * @param mixed Input value
+ * @return string Serialized JSON string
+ */
+function json_serialize($input)
+{
+ $input = rc_utf8_clean($input);
+
+ return json_encode($input);
+}
+
+
/**
* Explode quoted string
*
diff --git a/program/include/rcube_template.php b/program/include/rcube_template.php
index 19f2d430b..5226f8db8 100755
--- a/program/include/rcube_template.php
+++ b/program/include/rcube_template.php
@@ -414,12 +414,12 @@ class rcube_template extends rcube_html_page
{
$out = '';
if (!$this->framed && !empty($this->js_env)) {
- $out .= JS_OBJECT_NAME . '.set_env('.json_encode($this->js_env).");\n";
+ $out .= JS_OBJECT_NAME . '.set_env('.json_serialize($this->js_env).");\n";
}
foreach ($this->js_commands as $i => $args) {
$method = array_shift($args);
foreach ($args as $i => $arg) {
- $args[$i] = json_encode($arg);
+ $args[$i] = json_serialize($arg);
}
$parent = $this->framed || preg_match('/^parent\./', $method);
$out .= sprintf(