Skip to content

Commit a432b12

Browse files
committed
bug #52443 [Yaml] Fix uid binary parsing (mRoca)
This PR was merged into the 5.4 branch. Discussion ---------- [Yaml] Fix uid binary parsing | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | License | MIT Currently, on SF 5.4 & 6.4, a YAML file containing `{ uid: !!binary Ju0Yh+uqSXOagJZFTlUt8g== }` cannot be parsed because of a `preg_match` error: `Malformed UTF-8 characters, possibly incorrectly encoded`. This is because `preg_match` should not be run over a binary string, but this specific binary string matches the following tests : `\is_string($value) && '' !== $value && '&' === $value[0]` (the string starts with `0x26` , which is the UTF-8 `&` char). Commits ------- ce3e282 [Yaml] Fix uid binary parsing
2 parents 58353d1 + ce3e282 commit a432b12

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Symfony/Component/Yaml/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
}

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

Lines changed: 3 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy