]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/Utils.php
Makes escape a recursive function which handle array of strings
[github/shaarli/Shaarli.git] / application / Utils.php
index 3d819716316e78f1a884cb662723668a1529560d..5b8ca508576a94b0bafd0a6ee957a99fd3a7588e 100644 (file)
@@ -63,14 +63,22 @@ function endsWith($haystack, $needle, $case=true)
 
 /**
  * Htmlspecialchars wrapper
+ * Support multidimensional array of strings.
  *
- * @param string $str the string to escape.
+ * @param mixed $input Data to escape: a single string or an array of strings.
  *
  * @return string escaped.
  */
-function escape($str)
+function escape($input)
 {
-    return htmlspecialchars($str, ENT_COMPAT, 'UTF-8', false);
+    if (is_array($input)) {
+        $out = array();
+        foreach($input as $key => $value) {
+            $out[$key] = escape($value);
+        }
+        return $out;
+    }
+    return htmlspecialchars($input, ENT_COMPAT, 'UTF-8', false);
 }
 
 /**
@@ -226,7 +234,7 @@ function space2nbsp($text)
  *
  * @return string formatted description.
  */
-function format_description($description, $redirector) {
+function format_description($description, $redirector = false) {
     return nl2br(space2nbsp(text2clickable($description, $redirector)));
 }