|
69 | 69 | use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
|
70 | 70 | use Symfony\Component\Finder\Finder;
|
71 | 71 | use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator;
|
| 72 | +use Symfony\Component\Form\Extension\HtmlSanitizer\Type\TextTypeHtmlSanitizerExtension; |
72 | 73 | use Symfony\Component\Form\Form;
|
73 | 74 | use Symfony\Component\Form\FormTypeExtensionInterface;
|
74 | 75 | use Symfony\Component\Form\FormTypeGuesserInterface;
|
@@ -485,6 +486,9 @@ public function load(array $configs, ContainerBuilder $container)
|
485 | 486 | $container->removeDefinition('form.type_extension.form.validator');
|
486 | 487 | $container->removeDefinition('form.type_guesser.validator');
|
487 | 488 | }
|
| 489 | + if (!$this->isConfigEnabled($container, $config['html_sanitizer']) || !class_exists(TextTypeHtmlSanitizerExtension::class)) { |
| 490 | + $container->removeDefinition('form.type_extension.form.html_sanitizer'); |
| 491 | + } |
488 | 492 | } else {
|
489 | 493 | $container->removeDefinition('console.command.form_debug');
|
490 | 494 | }
|
@@ -2740,13 +2744,14 @@ private function registerHtmlSanitizerConfiguration(array $config, ContainerBuil
|
2740 | 2744 |
|
2741 | 2745 | // Create the sanitizer and link its config
|
2742 | 2746 | $sanitizerId = 'html_sanitizer.sanitizer.'.$sanitizerName;
|
2743 |
| - $container->register($sanitizerId, HtmlSanitizer::class)->addArgument(new Reference($configId)); |
| 2747 | + $container->register($sanitizerId, HtmlSanitizer::class) |
| 2748 | + ->addTag('html_sanitizer', ['sanitizer' => $sanitizerName]) |
| 2749 | + ->addArgument(new Reference($configId)); |
2744 | 2750 |
|
2745 |
| - $container->registerAliasForArgument($sanitizerId, HtmlSanitizerInterface::class, $sanitizerName); |
| 2751 | + if ('default' !== $sanitizerName) { |
| 2752 | + $container->registerAliasForArgument($sanitizerId, HtmlSanitizerInterface::class, $sanitizerName); |
| 2753 | + } |
2746 | 2754 | }
|
2747 |
| - |
2748 |
| - $default = $config['default'] ? 'html_sanitizer.sanitizer.'.$config['default'] : 'html_sanitizer'; |
2749 |
| - $container->setAlias(HtmlSanitizerInterface::class, new Reference($default)); |
2750 | 2755 | }
|
2751 | 2756 |
|
2752 | 2757 | private function resolveTrustedHeaders(array $headers): int
|
|
0 commit comments