aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Utils.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2016-03-20 14:14:38 +0100
committerArthurHoaro <arthur@hoa.ro>2016-03-25 19:17:59 +0100
commitee88a4bcc29da721cf43b750663aebeac4969517 (patch)
tree58fe3be81d4810e4daebfeb9d145064df6980dac /application/Utils.php
parent89baf23ddfaf82cc663e26f76c307ef8e4bf4b02 (diff)
downloadShaarli-ee88a4bcc29da721cf43b750663aebeac4969517.tar.gz
Shaarli-ee88a4bcc29da721cf43b750663aebeac4969517.tar.zst
Shaarli-ee88a4bcc29da721cf43b750663aebeac4969517.zip
Makes escape a recursive function which handle array of strings
Diffstat (limited to 'application/Utils.php')
-rw-r--r--application/Utils.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/application/Utils.php b/application/Utils.php
index bcf5bdb5..5b8ca508 100644
--- a/application/Utils.php
+++ b/application/Utils.php
@@ -63,14 +63,22 @@ function endsWith($haystack, $needle, $case=true)
63 63
64/** 64/**
65 * Htmlspecialchars wrapper 65 * Htmlspecialchars wrapper
66 * Support multidimensional array of strings.
66 * 67 *
67 * @param string $str the string to escape. 68 * @param mixed $input Data to escape: a single string or an array of strings.
68 * 69 *
69 * @return string escaped. 70 * @return string escaped.
70 */ 71 */
71function escape($str) 72function escape($input)
72{ 73{
73 return htmlspecialchars($str, ENT_COMPAT, 'UTF-8', false); 74 if (is_array($input)) {
75 $out = array();
76 foreach($input as $key => $value) {
77 $out[$key] = escape($value);
78 }
79 return $out;
80 }
81 return htmlspecialchars($input, ENT_COMPAT, 'UTF-8', false);
74} 82}
75 83
76/** 84/**