Skip to content

Commit

Permalink
Making h() preserve keys when escaping an array.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Oct 23, 2010
1 parent 7aaf7e6 commit 3e2d09a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cake/basics.php
Expand Up @@ -151,8 +151,8 @@ function sortByKey(&$array, $sortby, $order = 'asc', $type = SORT_NUMERIC) {
function h($text, $double = true, $charset = null) {
if (is_array($text)) {
$texts = array();
foreach ($text as $t) {
$texts[] = h($t, $double, $charset);
foreach ($text as $k => $t) {
$texts[$k] = h($t, $double, $charset);
}
return $texts;
}
Expand Down
8 changes: 8 additions & 0 deletions cake/tests/cases/basics.test.php
Expand Up @@ -228,6 +228,14 @@ public function testH() {
' '
);
$this->assertEqual($expected, $result);

$arr = array('f' => '<foo>', 'n' => '&nbsp;');
$result = h($arr, false);
$expected = array(
'f' => '&lt;foo&gt;',
'n' => '&nbsp;'
);
$this->assertEqual($expected, $result);
}

/**
Expand Down

0 comments on commit 3e2d09a

Please sign in to comment.