Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #724 from SimonEast/h_encoding

Prevent booleans from being encoded (converted to strings) by h() function
  • Loading branch information...
commit 4dd532d3a974c44c0392c58d37dc16218a8351b6 2 parents a03166c + 1ea457e
@markstory markstory authored
Showing with 11 additions and 0 deletions.
  1. +9 −0 lib/Cake/Test/Case/BasicsTest.php
  2. +2 −0  lib/Cake/basics.php
View
9 lib/Cake/Test/Case/BasicsTest.php
@@ -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
2  lib/Cake/basics.php
@@ -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;
Please sign in to comment.
Something went wrong with that request. Please try again.