Skip to content

Commit 902dfb7

Browse files
committed
[Yaml] Fix legacy support for omitting mapping key
1 parent e152862 commit 902dfb7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Inline.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ private static function dumpArray($value, $flags)
296296
*
297297
* @internal
298298
*/
299-
public static function parseScalar($scalar, $flags = 0, $delimiters = null, &$i = 0, $evaluate = true, $references = array())
299+
public static function parseScalar($scalar, $flags = 0, $delimiters = null, &$i = 0, $evaluate = true, $references = array(), $legacyOmittedKeySupport = false)
300300
{
301301
if (in_array($scalar[$i], array('"', "'"))) {
302302
// quoted scalar
@@ -318,7 +318,7 @@ public static function parseScalar($scalar, $flags = 0, $delimiters = null, &$i
318318
if (preg_match('/[ \t]+#/', $output, $match, PREG_OFFSET_CAPTURE)) {
319319
$output = substr($output, 0, $match[0][1]);
320320
}
321-
} elseif (preg_match('/^(.*?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
321+
} elseif (preg_match('/^(.'.($legacyOmittedKeySupport ? '+' : '*').'?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
322322
$output = $match[1];
323323
$i += strlen($output);
324324
} else {
@@ -475,7 +475,7 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
475475
}
476476

477477
// key
478-
$key = self::parseScalar($mapping, $flags, array(':', ' '), $i, false);
478+
$key = self::parseScalar($mapping, $flags, array(':', ' '), $i, false, array(), true);
479479

480480
if (':' !== $key && false === $i = strpos($mapping, ':', $i)) {
481481
break;

0 commit comments

Comments
 (0)