From 32ff3c6ef94119299a51e77ca97193a46e9c224b Mon Sep 17 00:00:00 2001 From: marcus Date: Tue, 10 Feb 2009 18:18:53 +0000 Subject: Refs #561: Split filtering into separate function git-svn-id: https://code.elgg.org/elgg/trunk@2709 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/input.php | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'engine/lib') 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; } /** -- cgit v1.2.3