Reapply the Yaml bugfix of #16745
This commit is contained in:
parent
7b8865bb87
commit
d9393d8099
@ -471,12 +471,14 @@ class Parser
|
||||
return $this->parseBlockScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), (int) abs($modifiers));
|
||||
}
|
||||
|
||||
if ('mapping' === $context && '"' !== $value[0] && "'" !== $value[0] && '[' !== $value[0] && '{' !== $value[0] && '!' !== $value[0] && false !== strpos($value, ': ')) {
|
||||
throw new ParseException('A colon cannot be used in an unquoted mapping value.');
|
||||
}
|
||||
|
||||
try {
|
||||
return Inline::parse($value, $exceptionOnInvalidType, $objectSupport, $objectForMap, $this->refs);
|
||||
$parsedValue = Inline::parse($value, $exceptionOnInvalidType, $objectSupport, $objectForMap, $this->refs);
|
||||
|
||||
if ('mapping' === $context && '"' !== $value[0] && "'" !== $value[0] && '[' !== $value[0] && '{' !== $value[0] && '!' !== $value[0] && false !== strpos($parsedValue, ': ')) {
|
||||
throw new ParseException('A colon cannot be used in an unquoted mapping value.');
|
||||
}
|
||||
|
||||
return $parsedValue;
|
||||
} catch (ParseException $e) {
|
||||
$e->setParsedLine($this->getRealCurrentLineNb() + 1);
|
||||
$e->setSnippet($this->currentLine);
|
||||
|
@ -785,8 +785,8 @@ EOF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage A colon cannot be used in an unquoted mapping value.
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage A colon cannot be used in an unquoted mapping value
|
||||
*/
|
||||
public function testColonInMappingValueException()
|
||||
{
|
||||
@ -796,6 +796,16 @@ EOF;
|
||||
|
||||
$this->parser->parse($yaml);
|
||||
}
|
||||
|
||||
public function testColonInMappingValueExceptionNotTriggeredByColonInComment()
|
||||
{
|
||||
$yaml = <<<EOT
|
||||
foo:
|
||||
bar: foobar # Note: a comment after a colon
|
||||
EOT;
|
||||
|
||||
$this->assertSame(array('foo' => array('bar' => 'foobar')), $this->parser->parse($yaml));
|
||||
}
|
||||
}
|
||||
|
||||
class B
|
||||
|
Reference in New Issue
Block a user