summaryrefslogtreecommitdiff
path: root/program/include/rcube_shared.inc
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2009-12-11 16:53:54 +0000
committeralecpl <alec@alec.pl>2009-12-11 16:53:54 +0000
commit2717f9f68e74277379c065d32bd0771976e49c86 (patch)
treef53fee8d67b8cac77e00e0ced33f538f5eb228d2 /program/include/rcube_shared.inc
parentf47e2dc5ea51853ade73565261db43f36ceeee92 (diff)
- use proper unicode cleanup for JSON, fixes #1486356
Diffstat (limited to 'program/include/rcube_shared.inc')
-rw-r--r--program/include/rcube_shared.inc17
1 files changed, 16 insertions, 1 deletions
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
*