[Yaml] Throw parse error on unfinished inline map

This commit is contained in:
Nicolas Grekas 2018-04-06 13:01:31 +02:00
parent c415e4c22a
commit 43599362a2
2 changed files with 12 additions and 0 deletions

View File

@ -231,6 +231,9 @@ class Inline
if (null !== $delimiters) {
$tmp = ltrim(substr($scalar, $i), ' ');
if ('' === $tmp) {
throw new ParseException(sprintf('Unexpected end of line, expected one of "%s".', implode($delimiters)));
}
if (!in_array($tmp[0], $delimiters)) {
throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i)));
}

View File

@ -432,4 +432,13 @@ class InlineTest extends TestCase
{
$this->assertSame(array('' => 'foo'), Inline::parse('{ "": foo }'));
}
/**
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
* @expectedExceptionMessage Unexpected end of line, expected one of ",}".
*/
public function testUnfinishedInlineMap()
{
Inline::parse("{abc: 'def'");
}
}