Skip to content

Commit d2ea460

Browse files
committed
1 parent b2d2535 commit d2ea460

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

system/core/Common.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,12 @@ function html_escape($var, $double_encode = TRUE)
752752

753753
if (is_array($var))
754754
{
755-
return array_map('html_escape', $var, array_fill(0, count($var), $double_encode));
755+
foreach (array_keys($var) as $key)
756+
{
757+
$var[$key] = html_escape($var[$key], $double_encode);
758+
}
759+
760+
return $var;
756761
}
757762

758763
return htmlspecialchars($var, ENT_QUOTES, config_item('charset'), $double_encode);

tests/codeigniter/core/Common_test.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public function test_html_escape()
4747
html_escape('Here is a string containing "quoted" text.'),
4848
'Here is a string containing "quoted" text.'
4949
);
50+
51+
$this->assertEquals(
52+
html_escape(array('associative' => 'and', array('multi' => 'dimentional'))),
53+
array('associative' => 'and', array('multi' => 'dimentional'))
54+
);
5055
}
5156

5257
}

user_guide_src/source/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Bug fixes for 3.0.3
2121
- Fixed a bug (#4171) - :doc:`Database Transactions <database/transactions>` didn't work with nesting in methods ``trans_begin()``, ``trans_commit()``, ``trans_rollback()``.
2222
- Fixed a bug where :doc:`Database Transaction <database/transactions>` methods ``trans_begin()``, ``trans_commit()``, ``trans_rollback()`` ignored failures.
2323
- Fixed a bug where all :doc:`Database Transaction <database/transactions>` methods returned TRUE while transactions are actually disabled.
24+
- Fixed a bug (#3201) - :doc:`Common function <general/common_functions>` :php:func:`html_escape()` modified keys of its array inputs.
2425

2526
Version 3.0.2
2627
=============

0 commit comments

Comments
 (0)