Skip to content

Commit

Permalink
Fix: htmlentities() shouldn't be called with null (#218)
Browse files Browse the repository at this point in the history
* Fix: htmlentities(): Passing null to parameter 1 ($string) of type string is deprecated
  • Loading branch information
fedeisas authored Oct 4, 2024
1 parent f6befea commit 3a472d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Liquid/StandardFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ public static function escape($input)
return $input;
}

if (is_null($input)) {
return '';
}

return htmlentities($input, ENT_QUOTES);
}

Expand Down
1 change: 1 addition & 0 deletions tests/Liquid/StandardFiltersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ public function testEscape()
$data = array(
"one Word's not" => "one Word's not",
"&><\"'" => "&amp;&gt;&lt;&quot;&#039;",
null => '',
);

foreach ($data as $element => $expected) {
Expand Down

0 comments on commit 3a472d5

Please sign in to comment.