Skip to content

Commit

Permalink
[Yaml] Fix uid binary parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
mRoca committed Nov 3, 2023
1 parent 6571eb0 commit f387675
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Inline.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
Expand Down
3 changes: 3 additions & 0 deletions Tests/InlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,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

0 comments on commit f387675

Please sign in to comment.