diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d6aac7..e807908 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip - Nothing ### Fixed -- Nothing +- Error emitted for empty string in guessable data. ### Deprecated - Nothing diff --git a/src/Rule/GuessableDataRule.php b/src/Rule/GuessableDataRule.php index a0a187f..b1efb88 100644 --- a/src/Rule/GuessableDataRule.php +++ b/src/Rule/GuessableDataRule.php @@ -131,7 +131,7 @@ private function contains(string $password, $data): bool } foreach ($strings as $string) { - if ('' !== $string && mb_stripos($password, $string) !== false) { + if ($string !== '' && mb_stripos($password, $string) !== false) { return true; } } diff --git a/tests/Rule/GuessableDataRuleTest.php b/tests/Rule/GuessableDataRuleTest.php index 5b9056b..0280f50 100644 --- a/tests/Rule/GuessableDataRuleTest.php +++ b/tests/Rule/GuessableDataRuleTest.php @@ -85,6 +85,17 @@ public function testPasswordCanContainGuessableDateInRule(): void self::assertFalse($rule->test($password)); } + /** + * @covers ::test + */ + public function testPasswordDoesNotContainEmptyString(): void + { + $rule = new GuessableDataRule(['']); + $password = new Password('foobar'); + + self::assertTrue($rule->test($password)); + } + /** * @covers ::test */