Skip to content

Commit e35658b

Browse files
committed
Merge branch 'hotfix/2.1.2'
2 parents f11d2a0 + c955acf commit e35658b

File tree

148 files changed

+324
-216
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+324
-216
lines changed

system/core/CodeIgniter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* @var string
3434
*
3535
*/
36-
define('CI_VERSION', '2.1.1');
36+
define('CI_VERSION', '2.1.2');
3737

3838
/**
3939
* CodeIgniter Branch (Core = TRUE, Reactor = FALSE)

system/core/Security.php

Lines changed: 81 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
1+
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
22
/**
33
* CodeIgniter
44
*
@@ -69,16 +69,16 @@ class CI_Security {
6969
* @access protected
7070
*/
7171
protected $_never_allowed_str = array(
72-
'document.cookie' => '[removed]',
73-
'document.write' => '[removed]',
74-
'.parentNode' => '[removed]',
75-
'.innerHTML' => '[removed]',
76-
'window.location' => '[removed]',
77-
'-moz-binding' => '[removed]',
78-
'<!--' => '&lt;!--',
79-
'-->' => '--&gt;',
80-
'<![CDATA[' => '&lt;![CDATA[',
81-
'<comment>' => '&lt;comment&gt;'
72+
'document.cookie' => '[removed]',
73+
'document.write' => '[removed]',
74+
'.parentNode' => '[removed]',
75+
'.innerHTML' => '[removed]',
76+
'window.location' => '[removed]',
77+
'-moz-binding' => '[removed]',
78+
'<!--' => '&lt;!--',
79+
'-->' => '--&gt;',
80+
'<![CDATA[' => '&lt;![CDATA[',
81+
'<comment>' => '&lt;comment&gt;'
8282
);
8383

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

9899
/**
@@ -364,9 +365,9 @@ public function xss_clean($str, $is_image = FALSE)
364365
* These words are compacted back to their correct state.
365366
*/
366367
$words = array(
367-
'javascript', 'expression', 'vbscript', 'script',
368-
'applet', 'alert', 'document', 'write', 'cookie', 'window'
369-
);
368+
'javascript', 'expression', 'vbscript', 'script', 'base64',
369+
'applet', 'alert', 'document', 'write', 'cookie', 'window'
370+
);
370371

371372
foreach ($words as $word)
372373
{
@@ -524,38 +525,38 @@ public function entity_decode($str, $charset='UTF-8')
524525
public function sanitize_filename($str, $relative_path = FALSE)
525526
{
526527
$bad = array(
527-
"../",
528-
"<!--",
529-
"-->",
530-
"<",
531-
">",
532-
"'",
533-
'"',
534-
'&',
535-
'$',
536-
'#',
537-
'{',
538-
'}',
539-
'[',
540-
']',
541-
'=',
542-
';',
543-
'?',
544-
"%20",
545-
"%22",
546-
"%3c", // <
547-
"%253c", // <
548-
"%3e", // >
549-
"%0e", // >
550-
"%28", // (
551-
"%29", // )
552-
"%2528", // (
553-
"%26", // &
554-
"%24", // $
555-
"%3f", // ?
556-
"%3b", // ;
557-
"%3d" // =
558-
);
528+
"../",
529+
"<!--",
530+
"-->",
531+
"<",
532+
">",
533+
"'",
534+
'"',
535+
'&',
536+
'$',
537+
'#',
538+
'{',
539+
'}',
540+
'[',
541+
']',
542+
'=',
543+
';',
544+
'?',
545+
"%20",
546+
"%22",
547+
"%3c", // <
548+
"%253c", // <
549+
"%3e", // >
550+
"%0e", // >
551+
"%28", // (
552+
"%29", // )
553+
"%2528", // (
554+
"%26", // &
555+
"%24", // $
556+
"%3f", // ?
557+
"%3b", // ;
558+
"%3d" // =
559+
);
559560

560561
if ( ! $relative_path)
561562
{
@@ -613,19 +614,20 @@ protected function _remove_evil_attributes($str, $is_image)
613614
*/
614615
unset($evil_attributes[array_search('xmlns', $evil_attributes)]);
615616
}
616-
617+
617618
do {
618619
$count = 0;
619620
$attribs = array();
620-
621+
621622
// find occurrences of illegal attribute strings without quotes
622-
preg_match_all("/(".implode('|', $evil_attributes).")\s*=\s*([^\s]*)/is", $str, $matches, PREG_SET_ORDER);
623-
623+
preg_match_all('/('.implode('|', $evil_attributes).')\s*=\s*([^\s>]*)/is', $str, $matches, PREG_SET_ORDER);
624+
624625
foreach ($matches as $attr)
625626
{
627+
626628
$attribs[] = preg_quote($attr[0], '/');
627629
}
628-
630+
629631
// find occurrences of illegal attribute strings with quotes (042 and 047 are octal quotes)
630632
preg_match_all("/(".implode('|', $evil_attributes).")\s*=\s*(\042|\047)([^\\2]*?)(\\2)/is", $str, $matches, PREG_SET_ORDER);
631633

@@ -637,11 +639,11 @@ protected function _remove_evil_attributes($str, $is_image)
637639
// replace illegal attribute strings that are inside an html tag
638640
if (count($attribs) > 0)
639641
{
640-
$str = preg_replace("/<(\/?[^><]+?)([^A-Za-z\-])(".implode('|', $attribs).")([\s><])([><]*)/i", '<$1$2$4$5', $str, -1, $count);
642+
$str = preg_replace("/<(\/?[^><]+?)([^A-Za-z<>\-])(.*?)(".implode('|', $attribs).")(.*?)([\s><])([><]*)/i", '<$1 $3$5$6$7', $str, -1, $count);
641643
}
642-
644+
643645
} while ($count);
644-
646+
645647
return $str;
646648
}
647649

@@ -682,9 +684,15 @@ protected function _sanitize_naughty_html($matches)
682684
*/
683685
protected function _js_link_removal($match)
684686
{
685-
$attributes = $this->_filter_attributes(str_replace(array('<', '>'), '', $match[1]));
686-
687-
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]);
687+
return str_replace(
688+
$match[1],
689+
preg_replace(
690+
'#href=.*?(alert\(|alert&\#40;|javascript\:|livescript\:|mocha\:|charset\=|window\.|document\.|\.cookie|<script|<xss|data\s*:)#si',
691+
'',
692+
$this->_filter_attributes(str_replace(array('<', '>'), '', $match[1]))
693+
),
694+
$match[0]
695+
);
688696
}
689697

690698
// --------------------------------------------------------------------
@@ -702,9 +710,15 @@ protected function _js_link_removal($match)
702710
*/
703711
protected function _js_img_removal($match)
704712
{
705-
$attributes = $this->_filter_attributes(str_replace(array('<', '>'), '', $match[1]));
706-
707-
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]);
713+
return str_replace(
714+
$match[1],
715+
preg_replace(
716+
'#src=.*?(alert\(|alert&\#40;|javascript\:|livescript\:|mocha\:|charset\=|window\.|document\.|\.cookie|<script|<xss|base64\s*,)#si',
717+
'',
718+
$this->_filter_attributes(str_replace(array('<', '>'), '', $match[1]))
719+
),
720+
$match[0]
721+
);
708722
}
709723

710724
// --------------------------------------------------------------------
@@ -819,14 +833,11 @@ protected function _validate_entities($str)
819833
*/
820834
protected function _do_never_allowed($str)
821835
{
822-
foreach ($this->_never_allowed_str as $key => $val)
823-
{
824-
$str = str_replace($key, $val, $str);
825-
}
836+
$str = str_replace(array_keys($this->_never_allowed_str), $this->_never_allowed_str, $str);
826837

827-
foreach ($this->_never_allowed_regex as $key => $val)
838+
foreach ($this->_never_allowed_regex as $regex)
828839
{
829-
$str = preg_replace("#".$key."#i", $val, $str);
840+
$str = preg_replace('#'.$regex.'#is', '[removed]', $str);
830841
}
831842

832843
return $str;

system/database/drivers/pdo/pdo_driver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @license http://codeigniter.com/user_guide/license.html
1010
* @author EllisLab Dev Team
1111
* @link http://codeigniter.com
12-
* @since Version 2.1.1
12+
* @since Version 2.1.2
1313
* @filesource
1414
*/
1515

system/database/drivers/pdo/pdo_forge.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @license http://codeigniter.com/user_guide/license.html
1010
* @author EllisLab Dev Team
1111
* @link http://codeigniter.com
12-
* @since Version 2.1.1
12+
* @since Version 2.1.2
1313
* @filesource
1414
*/
1515

system/database/drivers/pdo/pdo_result.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @license http://codeigniter.com/user_guide/license.html
1010
* @author EllisLab Dev Team
1111
* @link http://codeigniter.com
12-
* @since Version 2.1.1
12+
* @since Version 2.1.2
1313
* @filesource
1414
*/
1515

system/database/drivers/pdo/pdo_utility.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @license http://codeigniter.com/user_guide/license.html
1010
* @author EllisLab Dev Team
1111
* @link http://codeigniter.com
12-
* @since Version 2.1.1
12+
* @since Version 2.1.2
1313
* @filesource
1414
*/
1515

user_guide/changelog.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<div id="masthead">
2929
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
3030
<tr>
31-
<td><h1>CodeIgniter User Guide Version 2.1.1</h1></td>
31+
<td><h1>CodeIgniter User Guide Version 2.1.2</h1></td>
3232
<td id="breadcrumb_right"><a href="./toc.html">Table of Contents Page</a></td>
3333
</tr>
3434
</table>
@@ -57,6 +57,17 @@
5757

5858
<h1>Change Log</h1>
5959

60+
<h2>Version 2.1.2</h2>
61+
<p>Release Date: June 29, 2012</p>
62+
63+
<ul>
64+
<li>General Changes
65+
<ul>
66+
<li>Improved security in <kbd>xss_clean()</kbd>.</li>
67+
</ul>
68+
</li>
69+
</ul>
70+
6071
<h2>Version 2.1.1</h2>
6172
<p>Release Date: June 12, 2012</p>
6273

user_guide/database/active_record.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<div id="masthead">
2828
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
2929
<tr>
30-
<td><h1>CodeIgniter User Guide Version 2.1.1</h1></td>
30+
<td><h1>CodeIgniter User Guide Version 2.1.2</h1></td>
3131
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
3232
</tr>
3333
</table>

user_guide/database/caching.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<div id="masthead">
2929
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
3030
<tr>
31-
<td><h1>CodeIgniter User Guide Version 2.1.1</h1></td>
31+
<td><h1>CodeIgniter User Guide Version 2.1.2</h1></td>
3232
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
3333
</tr>
3434
</table>

user_guide/database/call_function.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<div id="masthead">
2929
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
3030
<tr>
31-
<td><h1>CodeIgniter User Guide Version 2.1.1</h1></td>
31+
<td><h1>CodeIgniter User Guide Version 2.1.2</h1></td>
3232
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
3333
</tr>
3434
</table>

0 commit comments

Comments
 (0)