diff --git a/api/src/loader/security.php b/api/src/loader/security.php index 7614b93b77..bc30dccc28 100755 --- a/api/src/loader/security.php +++ b/api/src/loader/security.php @@ -19,8 +19,9 @@ use EGroupware\Api; * @internal * @param array &$var reference of array to check * @param string $name ='' name of the array + * @param boolean $log = true Log the results of checking to the error log */ -function _check_script_tag(&$var,$name='') +function _check_script_tag(&$var,$name='',$log=true) { static $preg=null; //old: '/<\/?[^>]*\b(iframe|script|javascript|on(before)?(abort|blur|change|click|dblclick|error|focus|keydown|keypress|keyup|load|mousedown|mousemove|mouseout|mouseover|mouseup|reset|select|submit|unload))\b[^>]*>/i'; @@ -52,14 +53,17 @@ function _check_script_tag(&$var,$name='') $_REQUEST[$key] = $var[$key] = json_encode($json_data); continue; } - error_log(__FUNCTION__."(,$name) ${name}[$key] = ".$var[$key]); + //error_log(__FUNCTION__."(,$name) ${name}[$key] = ".$var[$key]); $GLOBALS['egw_unset_vars'][$name.'['.$key.']'] = $var[$key]; // attempt to clean the thing $var[$key] = $val = Api\Html\HtmLawed::purify($val); // check if we succeeded, if not drop the var anyway, keep the egw_unset_var in any case if (preg_match($preg,$val)) { - error_log("*** _check_script_tag($name): unset(${name}[$key]) with value $val***"); + if($log) + { + error_log("*** _check_script_tag($name): unset(${name}[$key]) with value $val***"); + } unset($var[$key]); } } @@ -70,105 +74,6 @@ function _check_script_tag(&$var,$name='') } } -/* some _check_script_tag tests, should be commented out by default -if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) // some tests -{ - if (!defined('EGW_INCLUDE_ROOT')) - { - define(EGW_INCLUDE_ROOT, realpath(dirname(__FILE__).'/../..')); - define(EGW_API_INC, realpath(dirname(__FILE__))); - } - - $total = $num_failed = 0; - $patterns = array( - // pattern => true: should fail, false: should not fail - '< script >alert(1)< / script >' => true, - 'blah' => true, - 'Click Me' => true, - // from https://www.acunetix.com/websitesecurity/cross-site-scripting/ - '' => true, - '' => true, - '