Skip to content

Commit 4359936

Browse files
[Yaml] Throw parse error on unfinished inline map
1 parent c415e4c commit 4359936

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Symfony/Component/Yaml/Inline.php

+3
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ public static function parseScalar($scalar, $delimiters = null, $stringDelimiter
231231

232232
if (null !== $delimiters) {
233233
$tmp = ltrim(substr($scalar, $i), ' ');
234+
if ('' === $tmp) {
235+
throw new ParseException(sprintf('Unexpected end of line, expected one of "%s".', implode($delimiters)));
236+
}
234237
if (!in_array($tmp[0], $delimiters)) {
235238
throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i)));
236239
}

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

+9
Original file line numberDiff line numberDiff line change
@@ -432,4 +432,13 @@ public function testTheEmptyStringIsAValidMappingKey()
432432
{
433433
$this->assertSame(array('' => 'foo'), Inline::parse('{ "": foo }'));
434434
}
435+
436+
/**
437+
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
438+
* @expectedExceptionMessage Unexpected end of line, expected one of ",}".
439+
*/
440+
public function testUnfinishedInlineMap()
441+
{
442+
Inline::parse("{abc: 'def'");
443+
}
435444
}

0 commit comments

Comments
 (0)