From af8665d973e63ace812ab1d433ae8b8dce5922c4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 17 Feb 2015 15:57:47 +0200 Subject: Fix #3572: CI_Security::_remove_evil_attributes() --- system/core/Security.php | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) (limited to 'system') diff --git a/system/core/Security.php b/system/core/Security.php index ccb141260..216f0e98b 100644 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -784,30 +784,15 @@ class CI_Security { } do { - $count = 0; - $attribs = array(); + $count = $temp_count = 0; - // find occurrences of illegal attribute strings with quotes (042 and 047 are octal quotes) - preg_match_all('/(?]+)(?]*)/is', $str, $matches, PREG_SET_ORDER); - - foreach ($matches as $attr) - { - $attribs[] = preg_quote($attr[0], '/'); - } - - // replace illegal attribute strings that are inside an html tag - if (count($attribs) > 0) - { - $str = preg_replace('/(<]+?)([^A-Za-z<>\-])(.*?)('.implode('|', $attribs).')(.*?)([\s><]?)([><]*)/i', '$1$2 $4$6$7$8', $str, -1, $count); - } + $str = preg_replace('/(<[^>]+)(?]*)/is', '$1[removed]', $str, -1, $temp_count); + $count += $temp_count; } while ($count); -- cgit v1.2.3-24-g4f1b