Skip to content

Commit 0055b23

Browse files
Merge branch '6.4' into 7.0
* 6.4: (28 commits) [Serializer] Fix `@method` annotation fix compatibility with Doctrine DBAL 4 ensure string type with mbstring func overloading enabled [HttpKernel] Fix quotes expectations in tests [Validator] updated Greek translation [Cache][HttpFoundation][Lock] Fix empty username/password for PDO PostgreSQL [HttpClient][WebProfilerBundle] Do not generate cURL command when files are uploaded render newline in front of all script elements fix test fixture fix tests [Cache] Fix property types in PdoAdapter PHP files cannot be executable without shebang [TwigBridge] Mark CodeExtension as @internal 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` Fix missing `profile` option for console commands [HttpFoundation][Lock] Makes MongoDB adapters usable with `ext-mongodb` only [HttpKernel] Preventing error 500 when function putenv is disabled ...
2 parents 5efffe8 + 4f9237a commit 0055b23

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
@@ -527,7 +527,7 @@ private static function parseMapping(string $mapping, int $flags, int &$i = 0, a
527527
if ('<<' === $key) {
528528
$output += $value;
529529
} elseif ($allowOverwrite || !isset($output[$key])) {
530-
if (!$isValueQuoted && \is_string($value) && '' !== $value && '&' === $value[0] && Parser::preg_match(Parser::REFERENCE_PATTERN, $value, $matches)) {
530+
if (!$isValueQuoted && \is_string($value) && '' !== $value && '&' === $value[0] && !self::isBinaryString($value) && Parser::preg_match(Parser::REFERENCE_PATTERN, $value, $matches)) {
531531
$references[$matches['ref']] = $matches['value'];
532532
$value = $matches['value'];
533533
}

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

@@ -927,6 +926,10 @@ private function isNextLineIndented(): bool
927926
} while (!$EOF && ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()));
928927

929928
if ($EOF) {
929+
for ($i = 0; $i < $movements; ++$i) {
930+
$this->moveToPreviousLine();
931+
}
932+
930933
return false;
931934
}
932935

Tests/InlineTest.php

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

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

Tests/ParserTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2698,6 +2698,44 @@ public static function circularReferenceProvider()
26982698
return $tests;
26992699
}
27002700

2701+
public function testBlockScalarArray()
2702+
{
2703+
$yaml = <<<'YAML'
2704+
anyOf:
2705+
- $ref: >-
2706+
#/string/bar
2707+
anyOfMultiline:
2708+
- $ref: >-
2709+
#/string/bar
2710+
second line
2711+
nested:
2712+
anyOf:
2713+
- $ref: >-
2714+
#/string/bar
2715+
YAML;
2716+
$expected = [
2717+
'anyOf' => [
2718+
0 => [
2719+
'$ref' => '#/string/bar',
2720+
],
2721+
],
2722+
'anyOfMultiline' => [
2723+
0 => [
2724+
'$ref' => '#/string/bar second line',
2725+
],
2726+
],
2727+
'nested' => [
2728+
'anyOf' => [
2729+
0 => [
2730+
'$ref' => '#/string/bar',
2731+
],
2732+
],
2733+
],
2734+
];
2735+
2736+
$this->assertSame($expected, $this->parser->parse($yaml));
2737+
}
2738+
27012739
/**
27022740
* @dataProvider indentedMappingData
27032741
*/

0 commit comments

Comments
 (0)