Prevent booleans from being encoded (converted to strings) by h() function #724

Merged
merged 1 commit into from Jul 26, 2012
@@ -225,6 +225,15 @@ public function testH() {
'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
@@ -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;