Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitf1cb4b5

Browse files
bug#32767 [Yaml] fix comment in multi line value (soufianZantar)
This PR was merged into the 3.4 branch.Discussion----------[Yaml] fix comment in multi line value| Q | A| ------------- | ---| Branch? | 4.3 and lower <!-- see below -->| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes <!-- please add some, will be required by reviewers -->| Fixed tickets |#32667 <!-- #-prefixed issue number(s), if any -->| License | MIT| Doc PR | symfony/symfony-docs#... <!-- required for new features --><!--Replace this notice by a short README for your feature/bugfix. This will help peopleunderstand your PR and can be used as a start for the documentation.Additionally (seehttps://symfony.com/roadmap): - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against branch 4.4. - Legacy code removals go to the master branch.-->Comments after blank lines are read as value in yaml.````$yaml = <<<YAMLparameters: abc# CommentYAML;var_dump(Symfony\Component\Yaml\Yaml::parse($yaml));````**Result before fix:**```array(1) { ["parameters"]=> string(13) "abc# Comment"}```**Result after fix:**```array(1) { ["parameters"]=> string(3) "abc"}```Commits-------dd945e3 fix(yml): fix comment in milti line value
2 parents1143b02 +dd945e3 commitf1cb4b5

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,9 @@ private function doParse($value, $flags)
436436
$value ='';
437437

438438
foreach ($this->linesas$line) {
439+
if ('' !==ltrim($line) &&'#' ===ltrim($line)[0]) {
440+
continue;
441+
}
439442
// If the indentation is not consistent at offset 0, it is to be considered as a ParseError
440443
if (0 ===$this->offset && !$deprecatedUsage &&isset($line[0]) &&'' ===$line[0]) {
441444
thrownewParseException('Unable to parse.',$this->getRealCurrentLineNb() +1,$this->currentLine,$this->filename);

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,6 +2292,18 @@ public function indentedMappingData()
22922292

22932293
return$tests;
22942294
}
2295+
2296+
publicfunctiontestMultiLineComment()
2297+
{
2298+
$yaml =<<<YAML
2299+
parameters:
2300+
abc
2301+
2302+
# Comment
2303+
YAML;
2304+
2305+
$this->assertSame(['parameters' =>'abc'],$this->parser->parse($yaml));
2306+
}
22952307
}
22962308

22972309
class B

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp