From 8541643756f031d8ec4d39f04e0564f20a2cff79 Mon Sep 17 00:00:00 2001 From: Uladzimir Tsykun Date: Fri, 10 Mar 2023 02:15:31 +0100 Subject: [PATCH] Fix support binary values in parameters. --- src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php | 2 +- .../Tests/Fixtures/containers/container8.php | 2 ++ .../DependencyInjection/Tests/Fixtures/php/services8.php | 2 ++ .../DependencyInjection/Tests/Fixtures/xml/services8.xml | 2 ++ .../DependencyInjection/Tests/Fixtures/yaml/services8.yml | 2 ++ 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php index 4f7b16d5f1035..402828b8e001f 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php @@ -320,7 +320,7 @@ private function convertParameters(array $parameters, string $type, \DOMElement $element->setAttribute('type', 'expression'); $text = $this->document->createTextNode(self::phpToXml((string) $value)); $element->appendChild($text); - } elseif (\is_string($value) && !preg_match('/^[^\x00-\x08\x0B\x0E-\x1A\x1C-\x1F\x7F]*+$/u', $value)) { + } elseif (\is_string($value) && !preg_match('/^[^\x00-\x08\x0B\x0C\x0E-\x1F\x7F]*+$/u', $value)) { $element->setAttribute('type', 'binary'); $text = $this->document->createTextNode(self::phpToXml(base64_encode($value))); $element->appendChild($text); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container8.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container8.php index aa09db4c0c021..0caa0fe3ef2b6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container8.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container8.php @@ -9,8 +9,10 @@ 'bar' => 'foo is %%foo bar', 'escape' => '@escapeme', 'values' => [true, false, null, 0, 1000.3, 'true', 'false', 'null'], + 'utf-8 valid string' => "\u{021b}\u{1b56}\ttest", 'binary' => "\xf0\xf0\xf0\xf0", 'binary-control-char' => "This is a Bell char \x07", + 'console banner' => "\e[37;44m#StandWith\e[30;43mUkraine\e[0m", 'null string' => 'null', 'string of digits' => '123', 'string of digits prefixed with minus character' => '-123', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php index 827e4bf394cf3..840bab52aa580 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php @@ -106,8 +106,10 @@ protected function getDefaultParameters(): array 6 => 'false', 7 => 'null', ], + 'utf-8 valid string' => 'ț᭖ test', 'binary' => 'ðððð', 'binary-control-char' => 'This is a Bell char ', + 'console banner' => '#StandWithUkraine', 'null string' => 'null', 'string of digits' => '123', 'string of digits prefixed with minus character' => '-123', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml index 906958d622a2b..8e095e7119fa9 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml @@ -18,8 +18,10 @@ false null + ț᭖ test 8PDw8A== VGhpcyBpcyBhIEJlbGwgY2hhciAH + G1szNzs0NG0jU3RhbmRXaXRoG1szMDs0M21Va3JhaW5lG1swbQ== null 123 -123 diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml index c410214e54c2b..ef9782f0a018b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml @@ -4,8 +4,10 @@ parameters: bar: 'foo is %%foo bar' escape: '@@escapeme' values: [true, false, null, 0, 1000.3, 'true', 'false', 'null'] + utf-8 valid string: "ț᭖\ttest" binary: !!binary 8PDw8A== binary-control-char: !!binary VGhpcyBpcyBhIEJlbGwgY2hhciAH + console banner: "\e[37;44m#StandWith\e[30;43mUkraine\e[0m" null string: 'null' string of digits: '123' string of digits prefixed with minus character: '-123'