Skip to content

Commit 38af7cc

Browse files
Merge branch '3.4' into 4.4
* 3.4: [VarDumper] fix for change in PHP 7.4.6 Added regression test for AccountStatusException behavior (ref #36822) embed resource name in error message [Serializer] fix issue with PHP 8 [Yaml] Fix escaped quotes in quoted multi-line string
2 parents fb3e343 + 7233ac2 commit 38af7cc

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

Parser.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,8 @@ private function parseValue(string $value, int $flags, string $context)
756756
$lines[] = trim($this->currentLine);
757757

758758
// quoted string values end with a line that is terminated with the quotation character
759-
if ('' !== $this->currentLine && substr($this->currentLine, -1) === $quotation) {
759+
$escapedLine = str_replace(['\\\\', '\\"'], '', $this->currentLine);
760+
if ('' !== $escapedLine && substr($escapedLine, -1) === $quotation) {
760761
break;
761762
}
762763
}

Tests/ParserTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,33 @@ public function testBlankLinesInQuotedMultiLineString()
15301530
$this->assertSame($expected, $this->parser->parse($yaml));
15311531
}
15321532

1533+
public function testEscapedQuoteInQuotedMultiLineString()
1534+
{
1535+
$yaml = <<<YAML
1536+
foobar: "foo
1537+
\\"bar\\"
1538+
baz"
1539+
YAML;
1540+
$expected = [
1541+
'foobar' => 'foo "bar" baz',
1542+
];
1543+
1544+
$this->assertSame($expected, $this->parser->parse($yaml));
1545+
}
1546+
1547+
public function testBackslashInQuotedMultiLineString()
1548+
{
1549+
$yaml = <<<YAML
1550+
foobar: "foo
1551+
bar\\\\"
1552+
YAML;
1553+
$expected = [
1554+
'foobar' => 'foo bar\\',
1555+
];
1556+
1557+
$this->assertSame($expected, $this->parser->parse($yaml));
1558+
}
1559+
15331560
public function testParseMultiLineUnquotedString()
15341561
{
15351562
$yaml = <<<EOT

0 commit comments

Comments
 (0)