Skip to content

Commit 95d8ce3

Browse files
VictoriaQfabpot
authored andcommitted
[Yaml] Fixed symfony#10597: Improved Yaml directive parsing
1 parent 1b39930 commit 95d8ce3

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Symfony/Component/Yaml/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ private function cleanup($value)
586586

587587
// strip YAML header
588588
$count = 0;
589-
$value = preg_replace('#^\%YAML[: ][\d\.]+.*\n#su', '', $value, -1, $count);
589+
$value = preg_replace('#^\%YAML[: ][\d\.]+.*\n#u', '', $value, -1, $count);
590590
$this->offset += $count;
591591

592592
// remove leading comments

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,17 @@ public function testReferenceResolvingInInlineStrings()
650650
EOF
651651
));
652652
}
653+
654+
public function testYamlDirective()
655+
{
656+
$yaml = <<<EOF
657+
%YAML 1.2
658+
---
659+
foo: 1
660+
bar: 2
661+
EOF;
662+
$this->assertEquals(array('foo' => 1, 'bar' => 2), $this->parser->parse($yaml));
663+
}
653664
}
654665

655666
class B

0 commit comments

Comments
 (0)