Prevent booleans from being encoded (converted to strings) by h() function, helps prevent accidental fatal errors in some PHP versions around 5.2.9

This commit is contained in:
Simon East 2012-07-20 12:37:36 +10:00
parent f65b52bf11
commit 1ea457e40e
2 changed files with 11 additions and 0 deletions

View file

@ -225,6 +225,15 @@ class BasicsTest extends CakeTestCase {
'n' => ' '
);
$this->assertEquals($expected, $result);
// Test that boolean values are not converted to strings
$result = h(false);
$this->assertFalse($result);
$arr = array('foo' => false, 'bar' => true);
$result = h($arr);
$this->assertFalse($result['foo']);
$this->assertTrue($result['bar']);
$obj = new stdClass();
$result = h($obj);

View file

@ -175,6 +175,8 @@ function h($text, $double = true, $charset = null) {
} else {
$text = '(object)' . get_class($text);
}
} elseif (is_bool($text)) {
return $text;
}
static $defaultCharset = false;