[Yaml] Fix escaped quotes in quoted multi-line string
This commit is contained in:
parent
9e0a39ee05
commit
2e99caacaf
@ -751,7 +751,8 @@ class Parser
|
||||
$lines[] = trim($this->currentLine);
|
||||
|
||||
// quoted string values end with a line that is terminated with the quotation character
|
||||
if ('' !== $this->currentLine && substr($this->currentLine, -1) === $quotation) {
|
||||
$escapedLine = str_replace(['\\\\', '\\"'], '', $this->currentLine);
|
||||
if ('' !== $escapedLine && substr($escapedLine, -1) === $quotation) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1650,6 +1650,33 @@ YAML;
|
||||
$this->assertSame($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function testEscapedQuoteInQuotedMultiLineString()
|
||||
{
|
||||
$yaml = <<<YAML
|
||||
foobar: "foo
|
||||
\\"bar\\"
|
||||
baz"
|
||||
YAML;
|
||||
$expected = [
|
||||
'foobar' => 'foo "bar" baz',
|
||||
];
|
||||
|
||||
$this->assertSame($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function testBackslashInQuotedMultiLineString()
|
||||
{
|
||||
$yaml = <<<YAML
|
||||
foobar: "foo
|
||||
bar\\\\"
|
||||
YAML;
|
||||
$expected = [
|
||||
'foobar' => 'foo bar\\',
|
||||
];
|
||||
|
||||
$this->assertSame($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function testParseMultiLineUnquotedString()
|
||||
{
|
||||
$yaml = <<<EOT
|
||||
|
Reference in New Issue
Block a user