diff --git a/src/Sanitizer.php b/src/Sanitizer.php index 5dbc941..faedeab 100644 --- a/src/Sanitizer.php +++ b/src/Sanitizer.php @@ -58,8 +58,13 @@ public static function create(array $config): SanitizerInterface return SanitizerBuilder::createDefault()->build($config); } - public function sanitize(string $html): string + public function sanitize(?string $html = null): ?string { + if(!$html) + { + return null; + } + $sanitized = $this->doSanitize($html); if ($this->logger) { diff --git a/src/SanitizerInterface.php b/src/SanitizerInterface.php index 8779063..d7ad1b3 100644 --- a/src/SanitizerInterface.php +++ b/src/SanitizerInterface.php @@ -20,5 +20,5 @@ */ interface SanitizerInterface { - public function sanitize(string $html): string; + public function sanitize(?string $html = null): ?string; } diff --git a/tests/SimpleSanitizerTest.php b/tests/SimpleSanitizerTest.php index 5df9845..bb1d5ec 100644 --- a/tests/SimpleSanitizerTest.php +++ b/tests/SimpleSanitizerTest.php @@ -24,6 +24,14 @@ public function createSanitizer(): SanitizerInterface public function provideFixtures(): array { return array_merge(parent::provideFixtures(), [ + /* + * Null value + */ + [ + null, + null + ] + /* * Normal tags */