Skip to content

Commit

Permalink
Fix passing a null input to h function
Browse files Browse the repository at this point in the history
Fix the following deprecation warning: Deprecated (8192): htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated [APP/Vendor/cakephp/cakephp/lib/Cake/basics.php, line 231]
  • Loading branch information
diegosurita authored and kamilwylegala committed Dec 19, 2023
1 parent 219d13c commit 8473730
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/Cake/Test/Case/BasicsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ public function testH() {
$obj = new CakeResponse(array('body' => 'Body content'));
$result = h($obj);
$this->assertEquals('Body content', $result);

$result = h(null);
$this->assertEquals('', $result);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions lib/Cake/basics.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ function h($text, $double = true, $charset = null) {
}
} elseif (is_bool($text)) {
return $text;
} elseif (is_null($text)) {
return '';
}

static $defaultCharset = false;
Expand Down

0 comments on commit 8473730

Please sign in to comment.