Skip to content

Commit 2dbb75a

Browse files
committed
removed usage of the deprecated StringUtils::equals() method
1 parent 8a6da3f commit 2dbb75a

File tree

3 files changed

+3
-15
lines changed

3 files changed

+3
-15
lines changed

src/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php

+1-11
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider;
1313

14-
use Symfony\Component\Security\Core\Util\StringUtils;
15-
1614
@trigger_error('The '.__NAMESPACE__.'\DefaultCsrfProvider is deprecated since version 2.4 and will be removed in version 3.0. Use the \Symfony\Component\Security\Csrf\TokenStorage\NativeSessionTokenStorage class instead.', E_USER_DEPRECATED);
1715

1816
/**
@@ -65,15 +63,7 @@ public function isCsrfTokenValid($intention, $token)
6563
{
6664
$expectedToken = $this->generateCsrfToken($intention);
6765

68-
if (function_exists('hash_equals')) {
69-
return hash_equals($expectedToken, $token);
70-
}
71-
72-
if (class_exists('Symfony\Component\Security\Core\Util\StringUtils')) {
73-
return StringUtils::equals($expectedToken, $token);
74-
}
75-
76-
return $token === $expectedToken;
66+
return hash_equals($expectedToken, $token);
7767
}
7868

7969
/**

src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Security\Http\Firewall;
1313

1414
use Symfony\Component\Security\Core\User\UserProviderInterface;
15-
use Symfony\Component\Security\Core\Util\StringUtils;
1615
use Symfony\Component\Security\Http\EntryPoint\DigestAuthenticationEntryPoint;
1716
use Psr\Log\LoggerInterface;
1817
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
@@ -100,7 +99,7 @@ public function handle(GetResponseEvent $event)
10099
return;
101100
}
102101

103-
if (!StringUtils::equals($serverDigestMd5, $digestAuth->getResponse())) {
102+
if (!hash_equals($serverDigestMd5, $digestAuth->getResponse())) {
104103
if (null !== $this->logger) {
105104
$this->logger->debug('Unexpected response from the DigestAuth received; is the header returning a clear text passwords?', array('expected' => $serverDigestMd5, 'received' => $digestAuth->getResponse()));
106105
}

src/Symfony/Component/Security/Http/RememberMe/PersistentTokenBasedRememberMeServices.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
2222
use Symfony\Component\Security\Core\Util\SecureRandomInterface;
2323
use Psr\Log\LoggerInterface;
24-
use Symfony\Component\Security\Core\Util\StringUtils;
2524

2625
/**
2726
* Concrete implementation of the RememberMeServicesInterface which needs
@@ -94,7 +93,7 @@ protected function processAutoLoginCookie(array $cookieParts, Request $request)
9493
list($series, $tokenValue) = $cookieParts;
9594
$persistentToken = $this->tokenProvider->loadTokenBySeries($series);
9695

97-
if (!StringUtils::equals($persistentToken->getTokenValue(), $tokenValue)) {
96+
if (!hash_equals($persistentToken->getTokenValue(), $tokenValue)) {
9897
throw new CookieTheftException('This token was already used. The account is possibly compromised.');
9998
}
10099

0 commit comments

Comments
 (0)