[Yaml] Throw parse error on unfinished inline map
This commit is contained in:
parent
c415e4c22a
commit
43599362a2
@ -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)));
|
||||
}
|
||||
|
@ -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'");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user