Skip to content

Commit

Permalink
Fix null values for Htmlclean::class rule
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Oct 28, 2024
1 parent 196f817 commit c0069c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Rules/Htmlclean.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class Htmlclean extends AbstractRule
*/
public function isValid(mixed $value): bool
{
return (strip_tags($value) == $value);
if (is_null($value)) {
return true;
}

return (strip_tags($value) == $value);
}
}
1 change: 1 addition & 0 deletions tests/Rules/HtmlcleanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static function dataProvider(): array
[true, 'attr="test"'],
[true, 'one < two'],
[true, 'two>one'],
[true, null],
[false, 'The quick brown fox jumps <strong>over</strong> the lazy dog.'],
[false, '<html>'],
[false, '<HTML>test</HTML>'],
Expand Down

0 comments on commit c0069c4

Please sign in to comment.