Skip to content

Commit 7c43418

Browse files
committed
Merge branch '7.2' into 7.3
* 7.2: properly skip signal test if the pcntl extension is not installed ensure that all supported e-mail validation modes can be configured [Security][LoginLink] Throw InvalidLoginLinkException on invalid parameters don't hardcode OS-depending constant values
2 parents 8ced9d9 + 11495f4 commit 7c43418

File tree

5 files changed

+66
-8
lines changed

5 files changed

+66
-8
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
use Symfony\Component\Translation\Translator;
4949
use Symfony\Component\TypeInfo\Type;
5050
use Symfony\Component\Uid\Factory\UuidFactory;
51+
use Symfony\Component\Validator\Constraints\Email;
5152
use Symfony\Component\Validator\Validation;
5253
use Symfony\Component\Webhook\Controller\WebhookController;
5354
use Symfony\Component\WebLink\HttpHeaderSerializer;
@@ -1075,7 +1076,7 @@ private function addValidationSection(ArrayNodeDefinition $rootNode, callable $e
10751076
->validate()->castToArray()->end()
10761077
->end()
10771078
->scalarNode('translation_domain')->defaultValue('validators')->end()
1078-
->enumNode('email_validation_mode')->values(['html5', 'loose', 'strict'])->defaultValue('html5')->end()
1079+
->enumNode('email_validation_mode')->values(Email::VALIDATION_MODES + ['loose'])->defaultValue('html5')->end()
10791080
->arrayNode('mapping')
10801081
->addDefaultsIfNotSet()
10811082
->fixXmlConfig('path')

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
2020
use Symfony\Component\RateLimiter\CompoundRateLimiterFactory;
2121
use Symfony\Component\RateLimiter\RateLimiterFactoryInterface;
22+
use Symfony\Component\Validator\Constraints\Email;
2223
use Symfony\Component\Workflow\Exception\InvalidDefinitionException;
2324

2425
class PhpFrameworkExtensionTest extends FrameworkExtensionTestCase
@@ -378,4 +379,31 @@ public function testRateLimiterCompoundPolicyInvalidLimiters()
378379
]);
379380
});
380381
}
382+
383+
/**
384+
* @dataProvider emailValidationModeProvider
385+
*/
386+
public function testValidatorEmailValidationMode(string $mode)
387+
{
388+
$this->expectNotToPerformAssertions();
389+
390+
$this->createContainerFromClosure(function (ContainerBuilder $container) use ($mode) {
391+
$container->loadFromExtension('framework', [
392+
'annotations' => false,
393+
'http_method_override' => false,
394+
'handle_all_throwables' => true,
395+
'php_errors' => ['log' => true],
396+
'validation' => [
397+
'email_validation_mode' => $mode,
398+
],
399+
]);
400+
});
401+
}
402+
403+
public function emailValidationModeProvider()
404+
{
405+
foreach (Email::VALIDATION_MODES as $mode) {
406+
yield [$mode];
407+
}
408+
}
381409
}

src/Symfony/Component/Console/Tests/SignalRegistry/SignalMapTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ class SignalMapTest extends TestCase
1818
{
1919
/**
2020
* @requires extension pcntl
21-
*
22-
* @testWith [2, "SIGINT"]
23-
* [9, "SIGKILL"]
24-
* [15, "SIGTERM"]
25-
* [31, "SIGSYS"]
2621
*/
27-
public function testSignalExists(int $signal, string $expected)
22+
public function testSignalExists()
2823
{
29-
$this->assertSame($expected, SignalMap::getSignalName($signal));
24+
$this->assertSame('SIGINT', SignalMap::getSignalName(\SIGINT));
25+
$this->assertSame('SIGKILL', SignalMap::getSignalName(\SIGKILL));
26+
$this->assertSame('SIGTERM', SignalMap::getSignalName(\SIGTERM));
27+
$this->assertSame('SIGSYS', SignalMap::getSignalName(\SIGSYS));
3028
}
3129

3230
public function testSignalDoesNotExist()

src/Symfony/Component/Security/Http/LoginLink/LoginLinkHandler.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,16 @@ public function consumeLoginLink(Request $request): UserInterface
8484
if (!$hash = $request->get('hash')) {
8585
throw new InvalidLoginLinkException('Missing "hash" parameter.');
8686
}
87+
if (!is_string($hash)) {
88+
throw new InvalidLoginLinkException('Invalid "hash" parameter.');
89+
}
90+
8791
if (!$expires = $request->get('expires')) {
8892
throw new InvalidLoginLinkException('Missing "expires" parameter.');
8993
}
94+
if (preg_match('/^\d+$/', $expires) !== 1) {
95+
throw new InvalidLoginLinkException('Invalid "expires" parameter.');
96+
}
9097

9198
try {
9299
$this->signatureHasher->acceptSignatureHash($userIdentifier, $expires, $hash);

src/Symfony/Component/Security/Http/Tests/LoginLink/LoginLinkHandlerTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,30 @@ public function testConsumeLoginLinkWithMissingExpiration()
240240
$linker->consumeLoginLink($request);
241241
}
242242

243+
public function testConsumeLoginLinkWithInvalidExpiration()
244+
{
245+
$user = new TestLoginLinkHandlerUser('weaverryan', 'ryan@symfonycasts.com', 'pwhash');
246+
$this->userProvider->createUser($user);
247+
248+
$this->expectException(InvalidLoginLinkException::class);
249+
$request = Request::create('/login/verify?user=weaverryan&hash=thehash&expires=%E2%80%AA1000000000%E2%80%AC');
250+
251+
$linker = $this->createLinker();
252+
$linker->consumeLoginLink($request);
253+
}
254+
255+
public function testConsumeLoginLinkWithInvalidHash()
256+
{
257+
$user = new TestLoginLinkHandlerUser('weaverryan', 'ryan@symfonycasts.com', 'pwhash');
258+
$this->userProvider->createUser($user);
259+
260+
$this->expectException(InvalidLoginLinkException::class);
261+
$request = Request::create('/login/verify?user=weaverryan&hash[]=an&hash[]=array&expires=1000000000');
262+
263+
$linker = $this->createLinker();
264+
$linker->consumeLoginLink($request);
265+
}
266+
243267
private function createSignatureHash(string $username, int $expires, array $extraFields = ['emailProperty' => 'ryan@symfonycasts.com', 'passwordProperty' => 'pwhash']): string
244268
{
245269
$hasher = new SignatureHasher($this->propertyAccessor, array_keys($extraFields), 's3cret');

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy