summaryrefslogtreecommitdiffstats
path: root/system/core
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-01-22 12:26:00 +0100
committerAndrey Andreev <narf@devilix.net>2014-01-22 12:26:00 +0100
commitc67c3fbb8e16b1ffb79c72bb91db04fcb005b2b1 (patch)
tree164976f99b4ec312c8442ac0f33747b3593115b8 /system/core
parent4356806dc0298363217694d727db9cad84a073e0 (diff)
CI_Security::_decode_entity() to replace dangerous HTML5 entities
Related to issue #2771
Diffstat (limited to 'system/core')
-rw-r--r--system/core/Security.php20
1 files changed, 19 insertions, 1 deletions
diff --git a/system/core/Security.php b/system/core/Security.php
index eb2695801..d6356f869 100644
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -62,6 +62,17 @@ class CI_Security {
);
/**
+ * HTML5 entities
+ *
+ * @var array
+ */
+ public $html5_entities = array(
+ '&colon;' => ':',
+ '&lpar;' => '(',
+ '&rpar;' => ')'
+ );
+
+ /**
* XSS Hash
*
* Random Hash for protecting URLs.
@@ -810,7 +821,14 @@ class CI_Security {
*/
protected function _decode_entity($match)
{
- return $this->entity_decode($match[0], strtoupper(config_item('charset')));
+ // entity_decode() won't convert dangerous HTML5 entities
+ // (it could, but ENT_HTML5 is only available since PHP 5.4),
+ // so we'll do that here
+ return str_ireplace(
+ array_keys($this->html5_entities),
+ array_values($this->html5_entities),
+ $this->entity_decode($match[0], strtoupper(config_item('charset')))
+ );
}
// --------------------------------------------------------------------