Skip to content

Commit c082fdb

Browse files
committed
Merge branch '7.3' into 7.4
* 7.3: Fix Warning: curl_multi_select(): timeout must be positive [PropertyInfo] Fix ReflectionExtractor handling of underscore-only property names ObjectNormalizer: allow null and scalar [Security] Fix `HttpUtils::createRequest()` when the context’s base URL isn’t empty [Serializer] fix Inherited properties normalization [OptionsResolver] Fix missing prototype key in nested error paths Bump Symfony version to 7.3.8 Update VERSION for 7.3.7 Update CHANGELOG for 7.3.7 Bump Symfony version to 6.4.30 Update VERSION for 6.4.29 Update CHANGELOG for 6.4.29 [Yaml] Fix parsing of unquoted multiline scalars with comments or blank lines [Clock] Align MockClock::sleep() behavior with NativeClock for negative values [OptionsResolver] Ensure remove() also unsets deprecation status Remove review state for Belarusian translations (entries 141 and 142) [ExpressionLanguage] Compile numbers with var_export in Compiler::repr for thread-safety compatibility with ext-redis 6.3 [Serializer] Fix BackedEnumNormalizer behavior with partial denormalization [HttpFoundation] Fix parsing pathinfo with no leading slash
2 parents 0d7c67f + 1c5f819 commit c082fdb

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

Parser.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,13 +769,22 @@ private function parseValue(string $value, int $flags, string $context): mixed
769769
$lines = [];
770770

771771
while ($this->moveToNextLine()) {
772+
if ($this->isCurrentLineBlank()) {
773+
$lines[] = '';
774+
continue;
775+
}
776+
772777
// unquoted strings end before the first unindented line
773778
if (0 === $this->getCurrentLineIndentation()) {
774779
$this->moveToPreviousLine();
775780

776781
break;
777782
}
778783

784+
if ($this->isCurrentLineComment()) {
785+
continue;
786+
}
787+
779788
$lines[] = trim($this->currentLine);
780789
}
781790

Tests/ParserTest.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,6 +1760,71 @@ public function testParseMultiLineUnquotedString()
17601760
$this->assertSame(['foo' => 'bar baz foobar foo', 'bar' => 'baz'], $this->parser->parse($yaml));
17611761
}
17621762

1763+
#[DataProvider('unquotedStringWithTrailingComment')]
1764+
public function testUnquotedMultilineScalarIgnoresComments(string $yaml, array $expected)
1765+
{
1766+
$this->assertSame($expected, $this->parser->parse($yaml));
1767+
}
1768+
1769+
public static function getUnquotedMultilineScalarIgnoresCommentsData()
1770+
{
1771+
yield 'comments interspersed' => [
1772+
<<<YAML
1773+
key: unquoted
1774+
# this comment should be ignored
1775+
next line
1776+
# another comment
1777+
final line
1778+
another_key: works
1779+
YAML,
1780+
[
1781+
'key' => 'unquoted next line final line',
1782+
'another_key' => 'works',
1783+
],
1784+
];
1785+
1786+
yield 'only comments' => [
1787+
<<<YAML
1788+
key: unquoted
1789+
# this comment should be ignored
1790+
# another comment
1791+
another_key: works
1792+
YAML,
1793+
[
1794+
'key' => 'unquoted',
1795+
'another_key' => 'works',
1796+
],
1797+
];
1798+
1799+
yield 'blank lines and comments' => [
1800+
<<<YAML
1801+
key: unquoted
1802+
next line
1803+
1804+
# this comment should be ignored
1805+
final line
1806+
another_key: works
1807+
YAML,
1808+
[
1809+
'key' => "unquoted next line\nfinal line",
1810+
'another_key' => 'works',
1811+
],
1812+
];
1813+
1814+
yield 'comment at end' => [
1815+
<<<YAML
1816+
key: unquoted
1817+
next line
1818+
# comment at end
1819+
another_key: works
1820+
YAML,
1821+
[
1822+
'key' => 'unquoted next line',
1823+
'another_key' => 'works',
1824+
],
1825+
];
1826+
}
1827+
17631828
#[DataProvider('unquotedStringWithTrailingComment')]
17641829
public function testParseMultiLineUnquotedStringWithTrailingComment(string $yaml, array $expected)
17651830
{

0 commit comments

Comments
 (0)