diff options
author | ArthurHoaro <arthur@hoa.ro> | 2016-03-20 14:14:38 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2016-03-25 19:17:59 +0100 |
commit | ee88a4bcc29da721cf43b750663aebeac4969517 (patch) | |
tree | 58fe3be81d4810e4daebfeb9d145064df6980dac /application | |
parent | 89baf23ddfaf82cc663e26f76c307ef8e4bf4b02 (diff) | |
download | Shaarli-ee88a4bcc29da721cf43b750663aebeac4969517.tar.gz Shaarli-ee88a4bcc29da721cf43b750663aebeac4969517.tar.zst Shaarli-ee88a4bcc29da721cf43b750663aebeac4969517.zip |
Makes escape a recursive function which handle array of strings
Diffstat (limited to 'application')
-rw-r--r-- | application/Utils.php | 14 |
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 | */ |
71 | function escape($str) | 72 | function 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 | /** |