Skip to content

Commit

Permalink
Merge branch '6.3' into 6.4
Browse files Browse the repository at this point in the history
* 6.3:
  fix tests
  Remove full DSNs from exception messages
  [Yaml] Fix uid binary parsing
  Disable the "Copy as cURL" button when the debug info are disabled
  [HttpClient] Replace `escapeshellarg` to prevent overpassing `ARG_MAX`
  [HttpKernel] Preventing error 500 when function putenv is disabled
  [PasswordHasher][Tests] Do not invoke methods with additional arguments in tests
  remove invalid group
  Fix block scalar array parsing
  • Loading branch information
xabbuh committed Nov 6, 2023
2 parents 96d3ed6 + 3493af8 commit 4f9237a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Inline.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ private static function parseMapping(string $mapping, int $flags, int &$i = 0, a
if ('<<' === $key) {
$output += $value;
} elseif ($allowOverwrite || !isset($output[$key])) {
if (!$isValueQuoted && \is_string($value) && '' !== $value && '&' === $value[0] && Parser::preg_match(Parser::REFERENCE_PATTERN, $value, $matches)) {
if (!$isValueQuoted && \is_string($value) && '' !== $value && '&' === $value[0] && !self::isBinaryString($value) && Parser::preg_match(Parser::REFERENCE_PATTERN, $value, $matches)) {
$references[$matches['ref']] = $matches['value'];
$value = $matches['value'];
}
Expand Down
7 changes: 5 additions & 2 deletions Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,8 @@ private function doParse(string $value, int $flags): mixed
|| self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->trimTag($values['value']), $matches)
)
) {
// this is a compact notation element, add to next block and parse
$block = $values['value'];
if ($this->isNextLineIndented()) {
if ($this->isNextLineIndented() || isset($matches['value']) && '>-' === $matches['value']) {
$block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + \strlen($values['leadspaces']) + 1);
}

Expand Down Expand Up @@ -932,6 +931,10 @@ private function isNextLineIndented(): bool
} while (!$EOF && ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()));

if ($EOF) {
for ($i = 0; $i < $movements; ++$i) {
$this->moveToPreviousLine();
}

return false;
}

Expand Down
3 changes: 3 additions & 0 deletions Tests/InlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ public static function getTestsForParse()

['[foo, bar: { foo: bar }]', ['foo', '1' => ['bar' => ['foo' => 'bar']]]],
['[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', ['foo', '@foo.baz', ['%foo%' => 'foo is %foo%', 'bar' => '%foo%'], true, '@service_container']],

// Binary string not utf8-compliant but starting with and utf8-equivalent "&" character
['{ uid: !!binary Ju0Yh+uqSXOagJZFTlUt8g== }', ['uid' => hex2bin('26ed1887ebaa49739a8096454e552df2')]],
];
}

Expand Down
38 changes: 38 additions & 0 deletions Tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2712,6 +2712,44 @@ public static function circularReferenceProvider()
return $tests;
}

public function testBlockScalarArray()
{
$yaml = <<<'YAML'
anyOf:
- $ref: >-
#/string/bar
anyOfMultiline:
- $ref: >-
#/string/bar
second line
nested:
anyOf:
- $ref: >-
#/string/bar
YAML;
$expected = [
'anyOf' => [
0 => [
'$ref' => '#/string/bar',
],
],
'anyOfMultiline' => [
0 => [
'$ref' => '#/string/bar second line',
],
],
'nested' => [
'anyOf' => [
0 => [
'$ref' => '#/string/bar',
],
],
],
];

$this->assertSame($expected, $this->parser->parse($yaml));
}

/**
* @dataProvider indentedMappingData
*/
Expand Down

0 comments on commit 4f9237a

Please sign in to comment.