Skip to content

Commit fa74c02

Browse files
committed
Merge branch 'MaxGiting/9.x' into 9.x
2 parents 25c8fed + 206e465 commit fa74c02

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

src/Illuminate/Hashing/AbstractHasher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ public function info($hashedValue)
1919
* Check the given plain value against a hash.
2020
*
2121
* @param string $value
22-
* @param string $hashedValue
22+
* @param string|null $hashedValue
2323
* @param array $options
2424
* @return bool
2525
*/
2626
public function check($value, $hashedValue, array $options = [])
2727
{
28-
if (strlen($hashedValue) === 0) {
28+
if (is_null($hashedValue) || strlen($hashedValue) === 0) {
2929
return false;
3030
}
3131

src/Illuminate/Hashing/Argon2IdHasher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Argon2IdHasher extends ArgonHasher
1010
* Check the given plain value against a hash.
1111
*
1212
* @param string $value
13-
* @param string $hashedValue
13+
* @param string|null $hashedValue
1414
* @param array $options
1515
* @return bool
1616
*
@@ -22,7 +22,7 @@ public function check($value, $hashedValue, array $options = [])
2222
throw new RuntimeException('This password does not use the Argon2id algorithm.');
2323
}
2424

25-
if (strlen($hashedValue) === 0) {
25+
if (is_null($hashedValue) || strlen($hashedValue) === 0) {
2626
return false;
2727
}
2828

tests/Hashing/HasherTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,26 @@
1010

1111
class HasherTest extends TestCase
1212
{
13+
public function testEmptyHashedValueReturnsFalse()
14+
{
15+
$hasher = new BcryptHasher();
16+
$this->assertTrue($hasher->check('password', ''));
17+
$hasher = new ArgonHasher();
18+
$this->assertTrue($hasher->check('password', ''));
19+
$hasher = new Argon2IdHasher();
20+
$this->assertTrue($hasher->check('password', ''));
21+
}
22+
23+
public function testNullHashedValueReturnsFalse()
24+
{
25+
$hasher = new BcryptHasher();
26+
$this->assertTrue($hasher->check('password', null));
27+
$hasher = new ArgonHasher();
28+
$this->assertTrue($hasher->check('password', null));
29+
$hasher = new Argon2IdHasher();
30+
$this->assertTrue($hasher->check('password', null));
31+
}
32+
1333
public function testBasicBcryptHashing()
1434
{
1535
$hasher = new BcryptHasher;

0 commit comments

Comments
 (0)