Skip to content

Commit d79f384

Browse files
Merge branch '4.4' into 5.2
* 4.4: Leverage str_contains/str_starts_with Leverage str_ends_with
2 parents 42f015c + bcda44d commit d79f384

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

Authorization/Voter/RoleVoter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function vote(TokenInterface $token, $subject, array $attributes)
3636
$roles = $this->extractRoles($token);
3737

3838
foreach ($attributes as $attribute) {
39-
if (!\is_string($attribute) || 0 !== strpos($attribute, $this->prefix)) {
39+
if (!\is_string($attribute) || !str_starts_with($attribute, $this->prefix)) {
4040
continue;
4141
}
4242

Encoder/MessageDigestPasswordEncoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function encodePassword(string $raw, ?string $salt)
7373
*/
7474
public function isPasswordValid(string $encoded, string $raw, ?string $salt)
7575
{
76-
if (\strlen($encoded) !== $this->encodedLength || false !== strpos($encoded, '$')) {
76+
if (\strlen($encoded) !== $this->encodedLength || str_contains($encoded, '$')) {
7777
return false;
7878
}
7979

Encoder/NativePasswordEncoder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ public function isPasswordValid(string $encoded, string $raw, ?string $salt): bo
9797
return false;
9898
}
9999

100-
if (0 !== strpos($encoded, '$argon')) {
100+
if (!str_starts_with($encoded, '$argon')) {
101101
// BCrypt encodes only the first 72 chars
102-
return (72 >= \strlen($raw) || 0 !== strpos($encoded, '$2')) && password_verify($raw, $encoded);
102+
return (72 >= \strlen($raw) || !str_starts_with($encoded, '$2')) && password_verify($raw, $encoded);
103103
}
104104

105105
if (\extension_loaded('sodium') && version_compare(\SODIUM_LIBRARY_VERSION, '1.0.14', '>=')) {

Encoder/Pbkdf2PasswordEncoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function encodePassword(string $raw, ?string $salt)
8080
*/
8181
public function isPasswordValid(string $encoded, string $raw, ?string $salt)
8282
{
83-
if (\strlen($encoded) !== $this->encodedLength || false !== strpos($encoded, '$')) {
83+
if (\strlen($encoded) !== $this->encodedLength || str_contains($encoded, '$')) {
8484
return false;
8585
}
8686

Encoder/SodiumPasswordEncoder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ public function isPasswordValid(string $encoded, string $raw, ?string $salt): bo
8484
return false;
8585
}
8686

87-
if (0 !== strpos($encoded, '$argon')) {
87+
if (!str_starts_with($encoded, '$argon')) {
8888
// Accept validating non-argon passwords for seamless migrations
89-
return (72 >= \strlen($raw) || 0 !== strpos($encoded, '$2')) && password_verify($raw, $encoded);
89+
return (72 >= \strlen($raw) || !str_starts_with($encoded, '$2')) && password_verify($raw, $encoded);
9090
}
9191

9292
if (\function_exists('sodium_crypto_pwhash_str_verify')) {

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=7.2.5",
2020
"symfony/event-dispatcher-contracts": "^1.1|^2",
21-
"symfony/polyfill-php80": "^1.15",
21+
"symfony/polyfill-php80": "^1.16",
2222
"symfony/service-contracts": "^1.1.6|^2",
2323
"symfony/deprecation-contracts": "^2.1"
2424
},

0 commit comments

Comments
 (0)