Skip to content

Commit a64bda2

Browse files
bug #48602 [HtmlSanitizer] Fix HtmlSanitizer default configuration behavior for allowed schemes (Titouan Galopin)
This PR was merged into the 6.1 branch. Discussion ---------- [HtmlSanitizer] Fix HtmlSanitizer default configuration behavior for allowed schemes | Q | A | ------------- | --- | Branch? | 6.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix symfony/symfony#48556 | License | MIT | Doc PR | - This issue happened not in the component but in the default configuration behavior (array was passed instead of null). Commits ------- 93e5160ec0 Fix HtmlSanitizer default configuration behavior for allowed schemes
2 parents 4df13ca + bc60544 commit a64bda2

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,10 +2738,14 @@ private function registerHtmlSanitizerConfiguration(array $config, ContainerBuil
27382738

27392739
// Settings
27402740
$def->addMethodCall('forceHttpsUrls', [$sanitizerConfig['force_https_urls']], true);
2741-
$def->addMethodCall('allowLinkSchemes', [$sanitizerConfig['allowed_link_schemes']], true);
2741+
if ($sanitizerConfig['allowed_link_schemes']) {
2742+
$def->addMethodCall('allowLinkSchemes', [$sanitizerConfig['allowed_link_schemes']], true);
2743+
}
27422744
$def->addMethodCall('allowLinkHosts', [$sanitizerConfig['allowed_link_hosts']], true);
27432745
$def->addMethodCall('allowRelativeLinks', [$sanitizerConfig['allow_relative_links']], true);
2744-
$def->addMethodCall('allowMediaSchemes', [$sanitizerConfig['allowed_media_schemes']], true);
2746+
if ($sanitizerConfig['allowed_media_schemes']) {
2747+
$def->addMethodCall('allowMediaSchemes', [$sanitizerConfig['allowed_media_schemes']], true);
2748+
}
27452749
$def->addMethodCall('allowMediaHosts', [$sanitizerConfig['allowed_media_hosts']], true);
27462750
$def->addMethodCall('allowRelativeMedias', [$sanitizerConfig['allow_relative_medias']], true);
27472751

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,7 +2140,9 @@ public function testHtmlSanitizerDefaultNullAllowedLinkMediaHost()
21402140

21412141
$calls = $container->getDefinition('html_sanitizer.config.custom_default')->getMethodCalls();
21422142
$this->assertContains(['allowLinkHosts', [null], true], $calls);
2143+
$this->assertContains(['allowRelativeLinks', [false], true], $calls);
21432144
$this->assertContains(['allowMediaHosts', [null], true], $calls);
2145+
$this->assertContains(['allowRelativeMedias', [false], true], $calls);
21442146
}
21452147

21462148
public function testHtmlSanitizerDefaultConfig()

0 commit comments

Comments
 (0)