diff options
author | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-02-10 18:18:53 +0000 |
---|---|---|
committer | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-02-10 18:18:53 +0000 |
commit | 32ff3c6ef94119299a51e77ca97193a46e9c224b (patch) | |
tree | 1c7bb62e6d3f914c33b4e1a2fd5a6013459af4db /engine | |
parent | a77be2ace10dab18dea29279549fc81ba2a5fb27 (diff) | |
download | elgg-32ff3c6ef94119299a51e77ca97193a46e9c224b.tar.gz elgg-32ff3c6ef94119299a51e77ca97193a46e9c224b.tar.bz2 |
Refs #561: Split filtering into separate function
git-svn-id: https://code.elgg.org/elgg/trunk@2709 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r-- | engine/lib/input.php | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/engine/lib/input.php b/engine/lib/input.php index f66d019ed..b338e530c 100644 --- a/engine/lib/input.php +++ b/engine/lib/input.php @@ -36,16 +36,9 @@ if ($filter_result) {
+
global $CONFIG;
- if (@include_once(dirname(dirname(dirname(__FILE__)))) . "/vendors/kses/kses.php") {
- if (!is_array($var)) {
- $var = kses($var, $CONFIG->allowedtags, $CONFIG->allowedprotocols);
- } else {
- foreach($var as $key => $el) {
- $var[$key] = kses($el, $CONFIG->allowedtags, $CONFIG->allowedprotocols);
- }
- }
- } + $var = filter_tags($var, $CONFIG->allowedtags, $CONFIG->allowedprotocols); }
return $var;
@@ -69,6 +62,31 @@ $CONFIG->input = array();
$CONFIG->input[trim($variable)] = trim($value);
+ }
+
+ /**
+ * Filter tags from a given string
+ * @param $var
+ * @return mixed The filtered result
+ */
+ function filter_tags($var, $allowedtags, $allowedprotocols)
+ {
+ $return = false;
+
+ if (@include_once(dirname(dirname(dirname(__FILE__)))) . "/vendors/kses/kses.php") {
+ if (!is_array($var)) {
+ $return = "";
+ $return = kses($var, $allowedtags, $allowedprotocols);
+ } else {
+ $return = array();
+
+ foreach($var as $key => $el) {
+ $return[$key] = kses($el, $allowedtags, $allowedprotocols);
+ }
+ }
+ }
+
+ return $return;
} /** |