summaryrefslogtreecommitdiffstats
path: root/lib/kolab_utils.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kolab_utils.php')
-rw-r--r--lib/kolab_utils.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/kolab_utils.php b/lib/kolab_utils.php
index e2602af..91dad55 100644
--- a/lib/kolab_utils.php
+++ b/lib/kolab_utils.php
@@ -206,4 +206,21 @@ class kolab_utils
return $str;
}
+
+ /**
+ * Escape string for use in javascript code
+ *
+ * @param string $str String
+ *
+ * @return string Escaped string
+ */
+ public static function js_escape($str)
+ {
+ return strtr($str, array(
+ '"' => '\\"',
+ "'" => "\\'",
+ "\\" => "\\\\",
+ "\n" => '\n',
+ ));
+ }
}