Skip to content

Commit

Permalink
Merge branch 'hotfix/2.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
wesbaker committed Jun 29, 2012
2 parents f11d2a0 + c955acf commit e35658b
Show file tree
Hide file tree
Showing 148 changed files with 324 additions and 216 deletions.
2 changes: 1 addition & 1 deletion system/core/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @var string
*
*/
define('CI_VERSION', '2.1.1');
define('CI_VERSION', '2.1.2');

/**
* CodeIgniter Branch (Core = TRUE, Reactor = FALSE)
Expand Down
151 changes: 81 additions & 70 deletions system/core/Security.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
Expand Down Expand Up @@ -69,16 +69,16 @@ class CI_Security {
* @access protected
*/
protected $_never_allowed_str = array(
'document.cookie' => '[removed]',
'document.write' => '[removed]',
'.parentNode' => '[removed]',
'.innerHTML' => '[removed]',
'window.location' => '[removed]',
'-moz-binding' => '[removed]',
'<!--' => '&lt;!--',
'-->' => '--&gt;',
'<![CDATA[' => '&lt;![CDATA[',
'<comment>' => '&lt;comment&gt;'
'document.cookie' => '[removed]',
'document.write' => '[removed]',
'.parentNode' => '[removed]',
'.innerHTML' => '[removed]',
'window.location' => '[removed]',
'-moz-binding' => '[removed]',
'<!--' => '&lt;!--',
'-->' => '--&gt;',
'<![CDATA[' => '&lt;![CDATA[',
'<comment>' => '&lt;comment&gt;'
);

/* never allowed, regex replacement */
Expand All @@ -89,10 +89,11 @@ class CI_Security {
* @access protected
*/
protected $_never_allowed_regex = array(
"javascript\s*:" => '[removed]',
"expression\s*(\(|&\#40;)" => '[removed]', // CSS and IE
"vbscript\s*:" => '[removed]', // IE, surprise!
"Redirect\s+302" => '[removed]'
'javascript\s*:',
'expression\s*(\(|&\#40;)', // CSS and IE
'vbscript\s*:', // IE, surprise!
'Redirect\s+302',
"([\"'])?data\s*:[^\\1]*?base64[^\\1]*?,[^\\1]*?\\1?"
);

/**
Expand Down Expand Up @@ -364,9 +365,9 @@ public function xss_clean($str, $is_image = FALSE)
* These words are compacted back to their correct state.
*/
$words = array(
'javascript', 'expression', 'vbscript', 'script',
'applet', 'alert', 'document', 'write', 'cookie', 'window'
);
'javascript', 'expression', 'vbscript', 'script', 'base64',
'applet', 'alert', 'document', 'write', 'cookie', 'window'
);

foreach ($words as $word)
{
Expand Down Expand Up @@ -524,38 +525,38 @@ public function entity_decode($str, $charset='UTF-8')
public function sanitize_filename($str, $relative_path = FALSE)
{
$bad = array(
"../",
"<!--",
"-->",
"<",
">",
"'",
'"',
'&',
'$',
'#',
'{',
'}',
'[',
']',
'=',
';',
'?',
"%20",
"%22",
"%3c", // <
"%253c", // <
"%3e", // >
"%0e", // >
"%28", // (
"%29", // )
"%2528", // (
"%26", // &
"%24", // $
"%3f", // ?
"%3b", // ;
"%3d" // =
);
"../",
"<!--",
"-->",
"<",
">",
"'",
'"',
'&',
'$',
'#',
'{',
'}',
'[',
']',
'=',
';',
'?',
"%20",
"%22",
"%3c", // <
"%253c", // <
"%3e", // >
"%0e", // >
"%28", // (
"%29", // )
"%2528", // (
"%26", // &
"%24", // $
"%3f", // ?
"%3b", // ;
"%3d" // =
);

if ( ! $relative_path)
{
Expand Down Expand Up @@ -613,19 +614,20 @@ protected function _remove_evil_attributes($str, $is_image)
*/
unset($evil_attributes[array_search('xmlns', $evil_attributes)]);
}

do {
$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);
preg_match_all('/('.implode('|', $evil_attributes).')\s*=\s*([^\s>]*)/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);

Expand All @@ -637,11 +639,11 @@ protected function _remove_evil_attributes($str, $is_image)
// 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$5', $str, -1, $count);
$str = preg_replace("/<(\/?[^><]+?)([^A-Za-z<>\-])(.*?)(".implode('|', $attribs).")(.*?)([\s><])([><]*)/i", '<$1 $3$5$6$7', $str, -1, $count);
}

} while ($count);

return $str;
}

Expand Down Expand Up @@ -682,9 +684,15 @@ protected function _sanitize_naughty_html($matches)
*/
protected function _js_link_removal($match)
{
$attributes = $this->_filter_attributes(str_replace(array('<', '>'), '', $match[1]));

return str_replace($match[1], preg_replace("#href=.*?(alert\(|alert&\#40;|javascript\:|livescript\:|mocha\:|charset\=|window\.|document\.|\.cookie|<script|<xss|base64\s*,)#si", "", $attributes), $match[0]);
return str_replace(
$match[1],
preg_replace(
'#href=.*?(alert\(|alert&\#40;|javascript\:|livescript\:|mocha\:|charset\=|window\.|document\.|\.cookie|<script|<xss|data\s*:)#si',
'',
$this->_filter_attributes(str_replace(array('<', '>'), '', $match[1]))
),
$match[0]
);
}

// --------------------------------------------------------------------
Expand All @@ -702,9 +710,15 @@ protected function _js_link_removal($match)
*/
protected function _js_img_removal($match)
{
$attributes = $this->_filter_attributes(str_replace(array('<', '>'), '', $match[1]));

return str_replace($match[1], preg_replace("#src=.*?(alert\(|alert&\#40;|javascript\:|livescript\:|mocha\:|charset\=|window\.|document\.|\.cookie|<script|<xss|base64\s*,)#si", "", $attributes), $match[0]);
return str_replace(
$match[1],
preg_replace(
'#src=.*?(alert\(|alert&\#40;|javascript\:|livescript\:|mocha\:|charset\=|window\.|document\.|\.cookie|<script|<xss|base64\s*,)#si',
'',
$this->_filter_attributes(str_replace(array('<', '>'), '', $match[1]))
),
$match[0]
);
}

// --------------------------------------------------------------------
Expand Down Expand Up @@ -819,14 +833,11 @@ protected function _validate_entities($str)
*/
protected function _do_never_allowed($str)
{
foreach ($this->_never_allowed_str as $key => $val)
{
$str = str_replace($key, $val, $str);
}
$str = str_replace(array_keys($this->_never_allowed_str), $this->_never_allowed_str, $str);

foreach ($this->_never_allowed_regex as $key => $val)
foreach ($this->_never_allowed_regex as $regex)
{
$str = preg_replace("#".$key."#i", $val, $str);
$str = preg_replace('#'.$regex.'#is', '[removed]', $str);
}

return $str;
Expand Down
2 changes: 1 addition & 1 deletion system/database/drivers/pdo/pdo_driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license http://codeigniter.com/user_guide/license.html
* @author EllisLab Dev Team
* @link http://codeigniter.com
* @since Version 2.1.1
* @since Version 2.1.2
* @filesource
*/

Expand Down
2 changes: 1 addition & 1 deletion system/database/drivers/pdo/pdo_forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license http://codeigniter.com/user_guide/license.html
* @author EllisLab Dev Team
* @link http://codeigniter.com
* @since Version 2.1.1
* @since Version 2.1.2
* @filesource
*/

Expand Down
2 changes: 1 addition & 1 deletion system/database/drivers/pdo/pdo_result.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license http://codeigniter.com/user_guide/license.html
* @author EllisLab Dev Team
* @link http://codeigniter.com
* @since Version 2.1.1
* @since Version 2.1.2
* @filesource
*/

Expand Down
2 changes: 1 addition & 1 deletion system/database/drivers/pdo/pdo_utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license http://codeigniter.com/user_guide/license.html
* @author EllisLab Dev Team
* @link http://codeigniter.com
* @since Version 2.1.1
* @since Version 2.1.2
* @filesource
*/

Expand Down
13 changes: 12 additions & 1 deletion user_guide/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.1</h1></td>
<td><h1>CodeIgniter User Guide Version 2.1.2</h1></td>
<td id="breadcrumb_right"><a href="./toc.html">Table of Contents Page</a></td>
</tr>
</table>
Expand Down Expand Up @@ -57,6 +57,17 @@

<h1>Change Log</h1>

<h2>Version 2.1.2</h2>
<p>Release Date: June 29, 2012</p>

<ul>
<li>General Changes
<ul>
<li>Improved security in <kbd>xss_clean()</kbd>.</li>
</ul>
</li>
</ul>

<h2>Version 2.1.1</h2>
<p>Release Date: June 12, 2012</p>

Expand Down
2 changes: 1 addition & 1 deletion user_guide/database/active_record.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.1</h1></td>
<td><h1>CodeIgniter User Guide Version 2.1.2</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
Expand Down
2 changes: 1 addition & 1 deletion user_guide/database/caching.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.1</h1></td>
<td><h1>CodeIgniter User Guide Version 2.1.2</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
Expand Down
2 changes: 1 addition & 1 deletion user_guide/database/call_function.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.1</h1></td>
<td><h1>CodeIgniter User Guide Version 2.1.2</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
Expand Down
2 changes: 1 addition & 1 deletion user_guide/database/configuration.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.1</h1></td>
<td><h1>CodeIgniter User Guide Version 2.1.2</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
Expand Down
2 changes: 1 addition & 1 deletion user_guide/database/connecting.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.1</h1></td>
<td><h1>CodeIgniter User Guide Version 2.1.2</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
Expand Down
2 changes: 1 addition & 1 deletion user_guide/database/examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.1</h1></td>
<td><h1>CodeIgniter User Guide Version 2.1.2</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
Expand Down
2 changes: 1 addition & 1 deletion user_guide/database/fields.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.1</h1></td>
<td><h1>CodeIgniter User Guide Version 2.1.2</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
Expand Down
2 changes: 1 addition & 1 deletion user_guide/database/forge.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.1</h1></td>
<td><h1>CodeIgniter User Guide Version 2.1.2</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
Expand Down
2 changes: 1 addition & 1 deletion user_guide/database/helpers.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.1</h1></td>
<td><h1>CodeIgniter User Guide Version 2.1.2</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
Expand Down
2 changes: 1 addition & 1 deletion user_guide/database/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>CodeIgniter User Guide Version 2.1.1</h1></td>
<td><h1>CodeIgniter User Guide Version 2.1.2</h1></td>
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
</tr>
</table>
Expand Down
Loading

0 comments on commit e35658b

Please sign in to comment.