Skip to content

Commit 3493af8

Browse files
committed
Merge branch '5.4' into 6.3
* 5.4: fix tests Remove full DSNs from exception messages [Yaml] Fix uid binary parsing [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
2 parents 9758b6c + f387675 commit 3493af8

File tree

4 files changed

+47
-3
lines changed

4 files changed

+47
-3
lines changed

Inline.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ private static function parseMapping(string $mapping, int $flags, int &$i = 0, a
531531
if ('<<' === $key) {
532532
$output += $value;
533533
} elseif ($allowOverwrite || !isset($output[$key])) {
534-
if (!$isValueQuoted && \is_string($value) && '' !== $value && '&' === $value[0] && Parser::preg_match(Parser::REFERENCE_PATTERN, $value, $matches)) {
534+
if (!$isValueQuoted && \is_string($value) && '' !== $value && '&' === $value[0] && !self::isBinaryString($value) && Parser::preg_match(Parser::REFERENCE_PATTERN, $value, $matches)) {
535535
$references[$matches['ref']] = $matches['value'];
536536
$value = $matches['value'];
537537
}

Parser.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,8 @@ private function doParse(string $value, int $flags): mixed
182182
|| self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->trimTag($values['value']), $matches)
183183
)
184184
) {
185-
// this is a compact notation element, add to next block and parse
186185
$block = $values['value'];
187-
if ($this->isNextLineIndented()) {
186+
if ($this->isNextLineIndented() || isset($matches['value']) && '>-' === $matches['value']) {
188187
$block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + \strlen($values['leadspaces']) + 1);
189188
}
190189

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

934933
if ($EOF) {
934+
for ($i = 0; $i < $movements; ++$i) {
935+
$this->moveToPreviousLine();
936+
}
937+
935938
return false;
936939
}
937940

Tests/InlineTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,9 @@ public static function getTestsForParse()
398398

399399
['[foo, bar: { foo: bar }]', ['foo', '1' => ['bar' => ['foo' => 'bar']]]],
400400
['[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', ['foo', '@foo.baz', ['%foo%' => 'foo is %foo%', 'bar' => '%foo%'], true, '@service_container']],
401+
402+
// Binary string not utf8-compliant but starting with and utf8-equivalent "&" character
403+
['{ uid: !!binary Ju0Yh+uqSXOagJZFTlUt8g== }', ['uid' => hex2bin('26ed1887ebaa49739a8096454e552df2')]],
401404
];
402405
}
403406

Tests/ParserTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2712,6 +2712,44 @@ public static function circularReferenceProvider()
27122712
return $tests;
27132713
}
27142714

2715+
public function testBlockScalarArray()
2716+
{
2717+
$yaml = <<<'YAML'
2718+
anyOf:
2719+
- $ref: >-
2720+
#/string/bar
2721+
anyOfMultiline:
2722+
- $ref: >-
2723+
#/string/bar
2724+
second line
2725+
nested:
2726+
anyOf:
2727+
- $ref: >-
2728+
#/string/bar
2729+
YAML;
2730+
$expected = [
2731+
'anyOf' => [
2732+
0 => [
2733+
'$ref' => '#/string/bar',
2734+
],
2735+
],
2736+
'anyOfMultiline' => [
2737+
0 => [
2738+
'$ref' => '#/string/bar second line',
2739+
],
2740+
],
2741+
'nested' => [
2742+
'anyOf' => [
2743+
0 => [
2744+
'$ref' => '#/string/bar',
2745+
],
2746+
],
2747+
],
2748+
];
2749+
2750+
$this->assertSame($expected, $this->parser->parse($yaml));
2751+
}
2752+
27152753
/**
27162754
* @dataProvider indentedMappingData
27172755
*/

0 commit comments

Comments
 (0)