summaryrefslogtreecommitdiffstats
path: root/system/core
diff options
context:
space:
mode:
authorbrian978 <dbrian89@yahoo.com>2012-12-03 20:18:20 +0100
committerbrian978 <dbrian89@yahoo.com>2012-12-03 20:18:20 +0100
commit160c7d16c4e0c92c030c0a41d1223f916a82089d (patch)
tree292c3214b970fae585cd9efca16e8c7250e6fc0c /system/core
parentc07c4855f808a0b3c0aac7d8056f38161185a4c7 (diff)
Added small improvement to the _remove_evil_attributes function
Signed-off-by: brian978 <dbrian89@yahoo.com>
Diffstat (limited to 'system/core')
-rw-r--r--system/core/Security.php11
1 files changed, 5 insertions, 6 deletions
diff --git a/system/core/Security.php b/system/core/Security.php
index c415544b6..4f2185db5 100644
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -642,17 +642,16 @@ class CI_Security {
$count = 0;
$attribs = array();
- // find occurrences of illegal attribute strings without quotes
- preg_match_all('/('.implode('|', $evil_attributes).')\s*=\s*([^\s>]*)/is', $str, $matches, PREG_SET_ORDER);
+ // find occurrences of illegal attribute strings with quotes (042 and 047 are octal quotes)
+ preg_match_all('/('.implode('|', $evil_attributes).')\s*=\s*(\042|\047)([^\\2]*?)(\\2)/is', $str, $matches, PREG_SET_ORDER);
foreach ($matches as $attr)
{
-
$attribs[] = preg_quote($attr[0], '/');
}
- // find occurrences of illegal attribute strings with quotes (042 and 047 are octal quotes)
- preg_match_all('/('.implode('|', $evil_attributes).')\s*=\s*(\042|\047)([^\\2]*?)(\\2)/is', $str, $matches, PREG_SET_ORDER);
+ // find occurrences of illegal attribute strings without quotes
+ preg_match_all('/('.implode('|', $evil_attributes).')\s*=\s*([^\s>]*)/is', $str, $matches, PREG_SET_ORDER);
foreach ($matches as $attr)
{
@@ -662,7 +661,7 @@ class CI_Security {
// 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 $3$5$6$7', $str, -1, $count);
+ $str = preg_replace('/(<?)(\/?[^><]+?)([^A-Za-z<>\-])(.*?)('.implode('|', $attribs).')(.*?)([\s><]?)([><]*)/i', '$1$2 $4$6$7$8', $str, -1, $count);
}
} while ($count);