Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0cd3efb

Browse filesBrowse files
committed
parse omitted inlined mapping values as null
1 parent 1099f6b commit 0cd3efb
Copy full SHA for 0cd3efb

File tree

2 files changed

+18
-2
lines changed
Filter options

2 files changed

+18
-2
lines changed

‎src/Symfony/Component/Yaml/Inline.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Inline.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public static function parseScalar($scalar, $flags = 0, $delimiters = null, $str
309309
if (preg_match('/[ \t]+#/', $output, $match, PREG_OFFSET_CAPTURE)) {
310310
$output = substr($output, 0, $match[0][1]);
311311
}
312-
} elseif (preg_match('/^(.+?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
312+
} elseif (preg_match('/^(.*?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
313313
$output = $match[1];
314314
$i += strlen($output);
315315
} else {
@@ -463,7 +463,7 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
463463
break;
464464
}
465465

466-
if (!isset($mapping[$i + 1]) || !in_array($mapping[$i + 1], array(' ', '[', ']', '{', '}'), true)) {
466+
if (!isset($mapping[$i + 1]) || !in_array($mapping[$i + 1], array(' ', ',', '[', ']', '{', '}'), true)) {
467467
@trigger_error('Using a colon that is not followed by an indication character (i.e. " ", ",", "[", "]", "{", "}" is deprecated since version 3.2 and will throw a ParseException in 4.0.', E_USER_DEPRECATED);
468468
}
469469

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Tests/InlineTest.php
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,4 +676,20 @@ public function testNotSupportedMissingValue()
676676
{
677677
Inline::parse('{this, is not, supported}');
678678
}
679+
680+
/**
681+
* @dataProvider getTestsForNullValues
682+
*/
683+
public function testParseMissingMappingValueAsNull($yaml, $expected)
684+
{
685+
$this->assertSame($expected, Inline::parse($yaml));
686+
}
687+
688+
public function getTestsForNullValues()
689+
{
690+
return array(
691+
'null before closing curly brace' => array('{foo:}', array('foo' => null)),
692+
'null before comma' => array('{foo:, bar: baz}', array('foo' => null, 'bar' => 'baz')),
693+
);
694+
}
679695
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.