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 9692f38

Browse filesBrowse files
committed
parse omitted inlined mapping values as null
1 parent 10c9d19 commit 9692f38
Copy full SHA for 9692f38

File tree

2 files changed

+17
-1
lines changed
Filter options

2 files changed

+17
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Inline.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ public static function parseScalar($scalar, $flags = 0, $delimiters = null, &$i
308308
if (preg_match('/[ \t]+#/', $output, $match, PREG_OFFSET_CAPTURE)) {
309309
$output = substr($output, 0, $match[0][1]);
310310
}
311-
} elseif (preg_match('/^(.+?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
311+
} elseif (preg_match('/^(.*?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
312312
$output = $match[1];
313313
$i += strlen($output);
314314
} else {

‎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
@@ -686,4 +686,20 @@ public function testVeryLongQuotedStrings()
686686

687687
$this->assertEquals($longStringWithQuotes, $arrayFromYaml['longStringWithQuotes']);
688688
}
689+
690+
/**
691+
* @dataProvider getTestsForNullValues
692+
*/
693+
public function testParseMissingMappingValueAsNull($yaml, $expected)
694+
{
695+
$this->assertSame($expected, Inline::parse($yaml));
696+
}
697+
698+
public function getTestsForNullValues()
699+
{
700+
return array(
701+
'null before closing curly brace' => array('{foo:}', array('foo' => null)),
702+
'null before comma' => array('{foo:, bar: baz}', array('foo' => null, 'bar' => 'baz')),
703+
);
704+
}
689705
}

0 commit comments

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