|
|
@@ -107,20 +107,6 @@ class Helper extends Object implements EventListener {
|
|
|
public $tags = array();
|
|
|
|
|
|
/**
|
|
|
- * Holds the content to be cleaned.
|
|
|
- *
|
|
|
- * @var mixed
|
|
|
- */
|
|
|
- protected $_tainted = null;
|
|
|
-
|
|
|
-/**
|
|
|
- * Holds the cleaned content.
|
|
|
- *
|
|
|
- * @var mixed
|
|
|
- */
|
|
|
- protected $_cleaned = null;
|
|
|
-
|
|
|
-/**
|
|
|
* The View instance this helper is attached to
|
|
|
*
|
|
|
* @var View
|
|
|
@@ -216,7 +202,7 @@ class Helper extends Object implements EventListener {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Lazy loads helpers. Provides access to deprecated request properties as well.
|
|
|
+ * Lazy loads helpers.
|
|
|
*
|
|
|
* @param string $name Name of the property being accessed.
|
|
|
* @return mixed Helper or property found at $name
|
|
|
@@ -229,39 +215,6 @@ class Helper extends Object implements EventListener {
|
|
|
if (isset($this->{$name})) {
|
|
|
return $this->{$name};
|
|
|
}
|
|
|
- switch ($name) {
|
|
|
- case 'base':
|
|
|
- case 'here':
|
|
|
- case 'webroot':
|
|
|
- case 'data':
|
|
|
- return $this->request->{$name};
|
|
|
- case 'action':
|
|
|
- return isset($this->request->params['action']) ? $this->request->params['action'] : '';
|
|
|
- case 'params':
|
|
|
- return $this->request;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-/**
|
|
|
- * Provides backwards compatibility access for setting values to the request object.
|
|
|
- *
|
|
|
- * @param string $name Name of the property being accessed.
|
|
|
- * @param mixed $value
|
|
|
- * @return void
|
|
|
- */
|
|
|
- public function __set($name, $value) {
|
|
|
- switch ($name) {
|
|
|
- case 'base':
|
|
|
- case 'here':
|
|
|
- case 'webroot':
|
|
|
- case 'data':
|
|
|
- $this->request->{$name} = $value;
|
|
|
- return;
|
|
|
- case 'action':
|
|
|
- $this->request->params['action'] = $value;
|
|
|
- return;
|
|
|
- }
|
|
|
- $this->{$name} = $value;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -422,30 +375,6 @@ class Helper extends Object implements EventListener {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Used to remove harmful tags from content. Removes a number of well known XSS attacks
|
|
|
- * from content. However, is not guaranteed to remove all possibilities. Escaping
|
|
|
- * content is the best way to prevent all possible attacks.
|
|
|
- *
|
|
|
- * @param string|array $output Either an array of strings to clean or a single string to clean.
|
|
|
- * @return string|array cleaned content for output
|
|
|
- */
|
|
|
- public function clean($output) {
|
|
|
- $this->_reset();
|
|
|
- if (empty($output)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- if (is_array($output)) {
|
|
|
- foreach ($output as $key => $value) {
|
|
|
- $return[$key] = $this->clean($value);
|
|
|
- }
|
|
|
- return $return;
|
|
|
- }
|
|
|
- $this->_tainted = $output;
|
|
|
- $this->_clean();
|
|
|
- return $this->_cleaned;
|
|
|
- }
|
|
|
-
|
|
|
-/**
|
|
|
* Returns a space-delimited string with items of the $options array. If a key
|
|
|
* of $options array happens to be one of those listed in `Helper::$_minimizedAttributes`
|
|
|
*
|
|
|
@@ -818,19 +747,6 @@ class Helper extends Object implements EventListener {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Returns a string generated by a helper method
|
|
|
- *
|
|
|
- * This method can be overridden in subclasses to do generalized output post-processing
|
|
|
- *
|
|
|
- * @param string $str String to be output.
|
|
|
- * @return string
|
|
|
- * @deprecated This method will be removed in future versions.
|
|
|
- */
|
|
|
- public function output($str) {
|
|
|
- return $str;
|
|
|
- }
|
|
|
-
|
|
|
-/**
|
|
|
* Get the View callbacks this helper is interested in.
|
|
|
*
|
|
|
* By defining one of the callback methods a helper is assumed
|
|
|
@@ -888,41 +804,4 @@ class Helper extends Object implements EventListener {
|
|
|
return empty($array) ? null : $array;
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * Resets the vars used by Helper::clean() to null
|
|
|
- *
|
|
|
- * @return void
|
|
|
- */
|
|
|
- protected function _reset() {
|
|
|
- $this->_tainted = null;
|
|
|
- $this->_cleaned = null;
|
|
|
- }
|
|
|
-
|
|
|
-/**
|
|
|
- * Removes harmful content from output
|
|
|
- *
|
|
|
- * @return void
|
|
|
- */
|
|
|
- protected function _clean() {
|
|
|
- $this->_cleaned = $this->_tainted;
|
|
|
- $this->_cleaned = str_replace(array("&", "<", ">"), array("&amp;", "&lt;", "&gt;"), $this->_cleaned);
|
|
|
- $this->_cleaned = preg_replace('#(&\#*\w+)[\x00-\x20]+;#u', "$1;", $this->_cleaned);
|
|
|
- $this->_cleaned = preg_replace('#(&\#x*)([0-9A-F]+);*#iu', "$1$2;", $this->_cleaned);
|
|
|
- $this->_cleaned = html_entity_decode($this->_cleaned, ENT_COMPAT, "UTF-8");
|
|
|
- $this->_cleaned = preg_replace('#(<[^>]+[\x00-\x20\"\'\/])(on|xmlns)[^>]*>#iUu', "$1>", $this->_cleaned);
|
|
|
- $this->_cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu', '$1=$2nojavascript...', $this->_cleaned);
|
|
|
- $this->_cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=([\'\"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu', '$1=$2novbscript...', $this->_cleaned);
|
|
|
- $this->_cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=*([\'\"]*)[\x00-\x20]*-moz-binding[\x00-\x20]*:#iUu', '$1=$2nomozbinding...', $this->_cleaned);
|
|
|
- $this->_cleaned = preg_replace('#([a-z]*)[\x00-\x20]*=([\'\"]*)[\x00-\x20]*data[\x00-\x20]*:#Uu', '$1=$2nodata...', $this->_cleaned);
|
|
|
- $this->_cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*expression[\x00-\x20]*\([^>]*>#iU', "$1>", $this->_cleaned);
|
|
|
- $this->_cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*behaviour[\x00-\x20]*\([^>]*>#iU', "$1>", $this->_cleaned);
|
|
|
- $this->_cleaned = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*>#iUu', "$1>", $this->_cleaned);
|
|
|
- $this->_cleaned = preg_replace('#</*\w+:\w[^>]*>#i', "", $this->_cleaned);
|
|
|
- do {
|
|
|
- $oldstring = $this->_cleaned;
|
|
|
- $this->_cleaned = preg_replace('#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>#i', "", $this->_cleaned);
|
|
|
- } while ($oldstring !== $this->_cleaned);
|
|
|
- $this->_cleaned = str_replace(array("&", "<", ">"), array("&amp;", "&lt;", "&gt;"), $this->_cleaned);
|
|
|
- }
|
|
|
-
|
|
|
}
|