Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DependencyInjection] Fix support binary values in parameters. #49651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only those chars is valid for XML
0x09 - tab
0x0a - \n
0x0d - \r

$element->setAttribute('type', 'binary');
$text = $this->document->createTextNode(self::phpToXml(base64_encode($value)));
$element->appendChild($text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
<parameter type="string">false</parameter>
<parameter type="string">null</parameter>
</parameter>
<parameter key="utf-8 valid string">&#x21B;&#x1B56; test</parameter>
<parameter key="binary" type="binary">8PDw8A==</parameter>
<parameter key="binary-control-char" type="binary">VGhpcyBpcyBhIEJlbGwgY2hhciAH</parameter>
<parameter key="console banner" type="binary">G1szNzs0NG0jU3RhbmRXaXRoG1szMDs0M21Va3JhaW5lG1swbQ==</parameter>
<parameter key="null string" type="string">null</parameter>
<parameter key="string of digits" type="string">123</parameter>
<parameter key="string of digits prefixed with minus character" type="string">-123</parameter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down