Skip to content

Commit ce3e282

Browse files
committed
[Yaml] Fix uid binary parsing
1 parent b421063 commit ce3e282

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Symfony/Component/Yaml/Inline.php

+1-1
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
}

src/Symfony/Component/Yaml/Tests/InlineTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,9 @@ public static function getTestsForParse()
368368

369369
['[foo, bar: { foo: bar }]', ['foo', '1' => ['bar' => ['foo' => 'bar']]]],
370370
['[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', ['foo', '@foo.baz', ['%foo%' => 'foo is %foo%', 'bar' => '%foo%'], true, '@service_container']],
371+
372+
// Binary string not utf8-compliant but starting with and utf8-equivalent "&" character
373+
['{ uid: !!binary Ju0Yh+uqSXOagJZFTlUt8g== }', ['uid' => hex2bin('26ed1887ebaa49739a8096454e552df2')]],
371374
];
372375
}
373376

0 commit comments

Comments
 (0)