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

Commitbdd66aa

Browse files
committed
bug#36004 [Yaml] fix dumping strings containing CRs (xabbuh)
This PR was merged into the 3.4 branch.Discussion----------[Yaml] fix dumping strings containing CRs| Q | A| ------------- | ---| Branch? | 3.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets || License | MIT| Doc PR |Commits-------da78704 [Yaml] fix dumping strings containing CRs
2 parentse44a3f5 +da78704 commitbdd66aa

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function dump($input, $inline = 0, $indent = 0, $flags = 0)
9999
$dumpAsMap = Inline::isHash($input);
100100

101101
foreach ($inputas$key =>$value) {
102-
if ($inline >=1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK &$flags &&\is_string($value) &&false !==strpos($value,"\n") &&false ===strpos($value,"\r\n")) {
102+
if ($inline >=1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK &$flags &&\is_string($value) &&false !==strpos($value,"\n") &&false ===strpos($value,"\r")) {
103103
// If the first line starts with a space character, the spec requires a blockIndicationIndicator
104104
// http://www.yaml.org/spec/1.2/spec.html#id2793979
105105
$blockIndentationIndicator = ('' ===substr($value,0,1)) ? (string)$this->indentation :'';

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,11 +613,26 @@ public function testDumpMultiLineStringAsScalarBlockWhenFirstLineHasLeadingSpace
613613
$this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block_leading_space_in_first_line.yml'),$this->dumper->dump($data,2,0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
614614
}
615615

616-
publicfunctiontestCarriageReturnIsMaintainedWhenDumpingAsMultiLineLiteralBlock()
616+
publicfunctiontestCarriageReturnFollowedByNewlineIsMaintainedWhenDumpingAsMultiLineLiteralBlock()
617617
{
618618
$this->assertSame("-\"a\\r\\nb\\nc\"\n",$this->dumper->dump(["a\r\nb\nc"],2,0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
619619
}
620620

621+
publicfunctiontestCarriageReturnNotFollowedByNewlineIsPreservedWhenDumpingAsMultiLineLiteralBlock()
622+
{
623+
$expected = <<<'YAML'
624+
parent:
625+
foo: "bar\n\rbaz: qux"
626+
627+
YAML;
628+
629+
$this->assertSame($expected,$this->dumper->dump([
630+
'parent' => [
631+
'foo' =>"bar\n\rbaz: qux",
632+
],
633+
],4,0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
634+
}
635+
621636
publicfunctiontestZeroIndentationThrowsException()
622637
{
623638
$this->expectException('InvalidArgumentException');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp