Skip to content

Commit 3a472d5

Browse files
authored
Fix: htmlentities() shouldn't be called with null (#218)
* Fix: htmlentities(): Passing null to parameter 1 ($string) of type string is deprecated
1 parent f6befea commit 3a472d5

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/Liquid/StandardFilters.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ public static function escape($input)
201201
return $input;
202202
}
203203

204+
if (is_null($input)) {
205+
return '';
206+
}
207+
204208
return htmlentities($input, ENT_QUOTES);
205209
}
206210

tests/Liquid/StandardFiltersTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ public function testEscape()
231231
$data = array(
232232
"one Word's not" => "one Word's not",
233233
"&><\"'" => "&amp;&gt;&lt;&quot;&#039;",
234+
null => '',
234235
);
235236

236237
foreach ($data as $element => $expected) {

0 commit comments

Comments
 (0)