Skip to content

Commit 0a528bc

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 95dd27e + 5b1086f commit 0a528bc

File tree

5 files changed

+49
-4
lines changed

5 files changed

+49
-4
lines changed

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, ...).')
Lines changed: 10 additions & 0 deletions
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+
]);
Lines changed: 13 additions & 0 deletions
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>
Lines changed: 5 additions & 0 deletions
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: ~

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');

0 commit comments

Comments
 (0)