10BC0 Merge branch '6.1' into 6.2 · symfony/symfony@5667f62 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5667f62

Browse files
Merge branch '6.1' into 6.2
* 6.1: [HttpKernel] Fix test sensitivity on xdebug.file_link_format [HttpKernel] Fix non-scalar check in surrogate fragment renderer [HtmlSanitizer] Allow null for sanitizer option `allowed_link_hosts` and `allowed_media_hosts` [Serializer] Fix wrong needsNormalization in TraceableEncoder [Debug][ErrorHandler] fix operator precedence [Cache] Ensured that redis adapter can use multiple redis sentinel hosts [DoctrineBridge] fix tests [Security] Allow redirect after login to absolute URLs
2 parents 43c09ab + d7b69a5 commit 5667f62

File tree

26 files changed

+129
-60
lines changed

26 files changed

+129
-60
lines changed

.github/workflows/integration-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ jobs:
171171
env:
172172
REDIS_HOST: 'localhost:16379'
173173
REDIS_CLUSTER_HOSTS: 'localhost:7000 localhost:7001 localhost:7002 localhost:7003 localhost:7004 localhost:7005'
174-
REDIS_SENTINEL_HOSTS: 'localhost:26379'
174+
REDIS_SENTINEL_HOSTS: 'localhost:26379 localhost:26379 localhost:26379'
175175
REDIS_SENTINEL_SERVICE: redis_sentinel
176176
MESSENGER_REDIS_DSN: redis://127.0.0.1:7006/messages
177177
MESSENGER_AMQP_DSN: amqp://localhost/%2f/messages

src/Symfony/Bridge/Doctrine/Tests/IdGenerator/EntityManager.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/Symfony/Bridge/Doctrine/Tests/IdGenerator/UlidGeneratorTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Tests\IdGenerator;
1313

14+
use Doctrine\ORM\EntityManager;
1415
use Doctrine\ORM\Mapping\Entity;
1516
use PHPUnit\Framework\TestCase;
1617
use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator;
@@ -21,7 +22,7 @@ class UlidGeneratorTest extends TestCase
2122
{
2223
public function testUlidCanBeGenerated()
2324
{
24-
$em = new EntityManager();
25+
$em = (new \ReflectionClass(EntityManager::class))->newInstanceWithoutConstructor();
2526
$generator = new UlidGenerator();
2627
$ulid = $generator->generate($em, new Entity());
2728

@@ -32,7 +33,7 @@ public function testUlidCanBeGenerated()
3233
public function testUlidFactory()
3334
{
3435
$ulid = new Ulid('00000000000000000000000000');
35-
$em = new EntityManager();
36+
$em = (new \ReflectionClass(EntityManager::class))->newInstanceWithoutConstructor();
3637
$factory = $this->createMock(UlidFactory::class);
3738
$factory->expects($this->any())
3839
->method('create')

src/Symfony/Bridge/Doctrine/Tests/IdGenerator/UuidGeneratorTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Tests\IdGenerator;
1313

14+
use Doctrine\ORM\EntityManager;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
1617
use Symfony\Component\Uid\Factory\UuidFactory;
@@ -22,7 +23,7 @@ class UuidGeneratorTest extends TestCase
2223
{
2324
public function testUuidCanBeGenerated()
2425
{
25-
$em = new EntityManager();
26+
$em = (new \ReflectionClass(EntityManager::class))->newInstanceWithoutConstructor();
2627
$generator = new UuidGenerator();
2728
$uuid = $generator->generate($em, new Entity());
2829

@@ -32,7 +33,7 @@ public function testUuidCanBeGenerated()
3233
public function testCustomUuidfactory()
3334
{
3435
$uuid = new UuidV4();
35-
$em = new EntityManager();
36+
$em = (new \ReflectionClass(EntityManager::class))->newInstanceWithoutConstructor();
3637
$factory = $this->createMock(UuidFactory::class);
3738
$factory->expects($this->any())
3839
->method('create')
@@ -44,7 +45,7 @@ public function testCustomUuidfactory()
4445

4546
public function testUuidfactory()
4647
{
47-
$em = new EntityManager();
48+
$em = (new \ReflectionClass(EntityManager::class))->newInstanceWithoutConstructor();
4849
$generator = new UuidGenerator();
4950
$this->assertInstanceOf(UuidV6::class, $generator->generate($em, new Entity()));
5051

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,9 +2224,13 @@ private function addHtmlSanitizerSection(ArrayNodeDefinition $rootNode, callable
22242224
->info('Allows only a given list of schemes to be used in links href attributes.')
22252225
->scalarPrototype()->end()
22262226
->end()
2227-
->arrayNode('allowed_link_hosts')
2227+
->variableNode('allowed_link_hosts')
22282228
->info('Allows only a given list of hosts to be used in links href attributes.')
2229-
->scalarPrototype()->end()
2229+
->defaultValue(null)
2230+
->validate()
2231+
->ifTrue(function ($v) { return !\is_array($v) && null !== $v; })
2232+
->thenInvalid('The "allowed_link_hosts" parameter must be an array or null')
2233+
->end()
22302234
->end()
22312235
->booleanNode('allow_relative_links')
22322236
->info('Allows relative URLs to be used in links href attributes.')
@@ -2236,9 +2240,13 @@ private function addHtmlSanitizerSection(ArrayNodeDefinition $rootNode, callable
22362240
->info('Allows only a given list of schemes to be used in media source attributes (img, audio, video, ...).')
22372241
->scalarPrototype()->end()
22382242
->end()
2239-
->arrayNode('allowed_media_hosts')
2243+
->variableNode('allowed_media_hosts')
22402244
->info('Allows only a given list of hosts to be used in media source attributes (img, audio, video, ...).')
2241-
->scalarPrototype()->end()
2245+
->defaultValue(null)
2246+
->validate()
2247+
->ifTrue(function ($v) { return !\is_array($v) && null !== $v; })
2248+
->thenInvalid('The "allowed_media_hosts" parameter must be an array or null')
2249+
->end()
22422250
->end()
22432251
->booleanNode('allow_relative_medias')
22442252
->info('Allows relative URLs to be used in media source attributes (img, audio, video, ...).')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', [
4+
'http_method_override' => false,
5+
'html_sanitizer' => [
6+
'sanitizers' => [
7+
'custom_default' => null,
8+
],
9+
],
10+
]);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" ?>
2+
3+
<container xmlns="http://symfony.com/schema/dic/services"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
6+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
7+
8+
<config xmlns="http://symfony.com/schema/dic/symfony" http-method-override="false">
9+
<html-sanitizer>
10+
<sanitizer name="custom_default"/>
11+
</html-sanitizer>
12+
</config>
13+
</container>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
framework:
2+
http_method_override: false
3+
html_sanitizer:
4+
sanitizers:
5+
custom_default: ~

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,6 +2111,15 @@ static function ($call) {
21112111
$this->assertFalse($container->hasAlias(HtmlSanitizerInterface::class.' $default'));
21122112
}
21132113

2114+
public function testHtmlSanitizerDefaultNullAllowedLinkMediaHost()
2115+
{
2116+
$container = $this->createContainerFromFile('html_sanitizer_default_allowed_link_and_media_hosts');
2117+
2118+
$calls = $container->getDefinition('html_sanitizer.config.custom_default')->getMethodCalls();
2119+
$this->assertContains(['allowLinkHosts', [null], true], $calls);
2120+
$this->assertContains(['allowMediaHosts', [null], true], $calls);
2121+
}
2122+
21142123
public function testHtmlSanitizerDefaultConfig()
21152124
{
21162125
$container = $this->createContainerFromFile('html_sanitizer_default_config');

src/Symfony/Component/Cache/Tests/Adapter/RedisAdapterSentinelTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public function testInvalidDSNHasBothClusterAndSentinel()
4747
public function testExceptionMessageWhenFailingToRetrieveMasterInformation()
4848
{
4949
$hosts = getenv('REDIS_SENTINEL_HOSTS');
50-
$firstHost = explode(' ', $hosts)[0];
50+
$dsn = 'redis:?host['.str_replace(' ', ']&host[', $hosts).']';
5151
$this->expectException(\Symfony\Component\Cache\Exception\InvalidArgumentException::class);
52-
$this->expectExceptionMessage('Failed to retrieve master information from master name "invalid-masterset-name" and address "'.$firstHost.'".');
53-
AbstractAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).']', ['redis_sentinel' => 'invalid-masterset-name']);
52+
$this->expectExceptionMessage('Failed to retrieve master information from sentinel "invalid-masterset-name" and dsn "'.$dsn.'".');
53+
AbstractAdapter::createConnection($dsn, ['redis_sentinel' => 'invalid-masterset-name']);
5454
}
5555
}

0 commit comments

Comments
 (0)
0