Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: symfony/yaml
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v6.3.7
Choose a base ref
...
head repository: symfony/yaml
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v6.3.8
Choose a head ref
  • 3 commits
  • 4 files changed
  • 3 contributors

Commits on Nov 1, 2023

  1. Fix block scalar array parsing

    NickSdot authored and xabbuh committed Nov 1, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    antfu Anthony Fu
    Copy the full SHA
    6571eb0 View commit details

Commits on Nov 3, 2023

  1. [Yaml] Fix uid binary parsing

    mRoca committed Nov 3, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    antfu Anthony Fu
    Copy the full SHA
    f387675 View commit details

Commits on Nov 6, 2023

  1. 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
    xabbuh committed Nov 6, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    antfu Anthony Fu
    Copy the full SHA
    3493af8 View commit details
Showing with 47 additions and 3 deletions.
  1. +1 −1 Inline.php
  2. +5 −2 Parser.php
  3. +3 −0 Tests/InlineTest.php
  4. +38 −0 Tests/ParserTest.php
2 changes: 1 addition & 1 deletion Inline.php
Original file line number Diff line number Diff line change
@@ -531,7 +531,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'];
}
7 changes: 5 additions & 2 deletions Parser.php
Original file line number Diff line number Diff line change
@@ -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);
}

@@ -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;
}

3 changes: 3 additions & 0 deletions Tests/InlineTest.php
Original file line number Diff line number Diff line change
@@ -398,6 +398,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')]],
];
}

38 changes: 38 additions & 0 deletions Tests/ParserTest.php
Original file line number Diff line number Diff line change
@@ -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
*/