From 8ad916f7a56dbe5d6b50826629e006cc939a3f61 Mon Sep 17 00:00:00 2001 From: matlec Date: Sat, 2 Aug 2025 18:55:44 +0200 Subject: [PATCH] [FrameworkBundle] Escape parameters when serializing a ContainerBuilder --- .../Compiler/ContainerBuilderDebugDumpPass.php | 16 +++++++++++++++- .../Functional/ContainerLintCommandTest.php | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ContainerBuilderDebugDumpPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ContainerBuilderDebugDumpPass.php index b3a036c379b7f..ff90207969414 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ContainerBuilderDebugDumpPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ContainerBuilderDebugDumpPass.php @@ -54,7 +54,7 @@ public function process(ContainerBuilder $container): void if (($bag = $container->getParameterBag()) instanceof EnvPlaceholderParameterBag) { (new ResolveEnvPlaceholdersPass(null))->process($dump); - $dump->__construct(new EnvPlaceholderParameterBag($container->resolveEnvPlaceholders($bag->all()))); + $dump->__construct(new EnvPlaceholderParameterBag($container->resolveEnvPlaceholders($this->escapeParameters($bag->all())))); } $fs = new Filesystem(); @@ -68,4 +68,18 @@ public function process(ContainerBuilder $container): void } } } + + private function escapeParameters(array $parameters): array + { + $params = []; + foreach ($parameters as $k => $v) { + $params[$k] = match (true) { + \is_array($v) => $this->escapeParameters($v), + \is_string($v) => str_replace('%', '%%', $v), + default => $v, + }; + } + + return $params; + } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerLintCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerLintCommandTest.php index f0b6b4bd57b07..106f6b776cea5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerLintCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerLintCommandTest.php @@ -44,6 +44,7 @@ public static function containerLintProvider(): array { return [ ['escaped_percent.yml', false, 0, 'The container was linted successfully'], + ['escaped_percent.yml', true, 0, 'The container was linted successfully'], ['missing_env_var.yml', false, 0, 'The container was linted successfully'], ['missing_env_var.yml', true, 1, 'Environment variable not found: "BAR"'], ]; 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