Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a8cb3cd

Browse filesBrowse files
committed
bug #36743 [Yaml] Fix escaped quotes in quoted multi-line string (ossinkine)
This PR was merged into the 3.4 branch. Discussion ---------- [Yaml] Fix escaped quotes in quoted multi-line string | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | License | MIT This PR continues #19304 This PR fixes incorrect parsing quoted multi-line string which contain escaped quotes, see tests Commits ------- 2e99caa [Yaml] Fix escaped quotes in quoted multi-line string
2 parents 1e1060f + 2e99caa commit a8cb3cd
Copy full SHA for a8cb3cd

File tree

Expand file treeCollapse file tree

2 files changed

+29
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+29
-1
lines changed

‎src/Symfony/Component/Yaml/Parser.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Parser.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,8 @@ private function parseValue($value, $flags, $context)
757757
$lines[] = trim($this->currentLine);
758758

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

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Tests/ParserTest.php
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,6 +1650,33 @@ public function testBlankLinesInQuotedMultiLineString()
16501650
$this->assertSame($expected, $this->parser->parse($yaml));
16511651
}
16521652

1653+
public function testEscapedQuoteInQuotedMultiLineString()
1654+
{
1655+
$yaml = <<<YAML
1656+
foobar: "foo
1657+
\\"bar\\"
1658+
baz"
1659+
YAML;
1660+
$expected = [
1661+
'foobar' => 'foo "bar" baz',
1662+
];
1663+
1664+
$this->assertSame($expected, $this->parser->parse($yaml));
1665+
}
1666+
1667+
public function testBackslashInQuotedMultiLineString()
1668+
{
1669+
$yaml = <<<YAML
1670+
foobar: "foo
1671+
bar\\\\"
1672+
YAML;
1673+
$expected = [
1674+
'foobar' => 'foo bar\\',
1675+
];
1676+
1677+
$this->assertSame($expected, $this->parser->parse($yaml));
1678+
}
1679+
16531680
public function testParseMultiLineUnquotedString()
16541681
{
16551682
$yaml = <<<EOT

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.