File tree 2 files changed +50
-0
lines changed
src/Symfony/Component/Yaml
2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -301,6 +301,10 @@ public function parse($value, $flags = 0)
301
301
throw new ParseException ('Multiple documents are not supported. ' , $ this ->currentLineNb + 1 , $ this ->currentLine );
302
302
}
303
303
304
+ if (isset ($ this ->currentLine [1 ]) && '? ' === $ this ->currentLine [0 ] && ' ' === $ this ->currentLine [1 ]) {
305
+ throw new ParseException ('The parser does not support complex mappings. ' , $ this ->currentLineNb + 1 , $ this ->currentLine );
306
+ }
307
+
304
308
// 1-liner optionally followed by newline(s)
305
309
if (is_string ($ value ) && $ this ->lines [0 ] === trim ($ value )) {
306
310
try {
Original file line number Diff line number Diff line change @@ -1640,6 +1640,52 @@ public function testExceptionWhenUsingUnsuportedBuiltInTags()
1640
1640
$ this ->parser ->parse ('!!foo ' );
1641
1641
}
1642
1642
1643
+ /**
1644
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
1645
+ * @expectedExceptionMessageRegExp /^The parser does not support complex mappings/
1646
+ */
1647
+ public function testComplexMappingThrowsParseException ()
1648
+ {
1649
+ $ yaml = <<<YAML
1650
+ ? "1"
1651
+ :
1652
+ name: végétalien
1653
+ YAML ;
1654
+
1655
+ $ this ->parser ->parse ($ yaml );
1656
+ }
1657
+
1658
+ /**
1659
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
1660
+ * @expectedExceptionMessageRegExp /^The parser does not support complex mappings/
1661
+ */
1662
+ public function testComplexMappingNestedInMappingThrowsParseException ()
1663
+ {
1664
+ $ yaml = <<<YAML
1665
+ diet:
1666
+ ? "1"
1667
+ :
1668
+ name: végétalien
1669
+ YAML ;
1670
+
1671
+ $ this ->parser ->parse ($ yaml );
1672
+ }
1673
+
1674
+ /**
1675
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
1676
+ * @expectedExceptionMessageRegExp /^The parser does not support complex mappings/
1677
+ */
1678
+ public function testComplexMappingNestedInSequenceThrowsParseException ()
1679
+ {
1680
+ $ yaml = <<<YAML
1681
+ - ? "1"
1682
+ :
1683
+ name: végétalien
1684
+ YAML ;
1685
+
1686
+ $ this ->parser ->parse ($ yaml );
1687
+ }
1688
+
1643
1689
private function loadTestsFromFixtureFiles ($ testsFile )
1644
1690
{
1645
1691
$ parser = new Parser ();
You can’t perform that action at this time.
0 commit comments