mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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:
parent
f65b52bf11
commit
1ea457e40e
2 changed files with 11 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue