8000 #9105 Remove white spaces from yml parameter with html · symfony/symfony@3ca9d2d · GitHub
[go: up one dir, main page]

Skip to content

Commit 3ca9d2d

Browse files
committed
#9105 Remove white spaces from yml parameter with html
1 parent cbce472 commit 3ca9d2d

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/Symfony/Component/Yaml/Parser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ private function parseFoldedScalar($separator, $indicator = '', $indentation = 0
482482
if ('>' === $separator) {
483483
preg_match('/(\n*)$/', $text, $matches);
484484
$text = preg_replace('/(?<!\n)\n(?!\n)/', ' ', rtrim($text, "\n"));
485+
$text = preg_replace('/>\s+</', '><', $text);
485486
$text .= $matches[1];
486487
}
487488

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,42 @@ public function testNestedFoldedStringBlockWithComments()
611611
EOF
612612
));
613613
}
614+
615+
public function testHtmlStringWithWhiteSpaces()
616+
{
617+
$this->assertEquals(array('test' => <<<EOT
618+
<h2>A heading</h2><ul><li>a list</li><li>may be a good example</li></ul>
619+
EOT
620+
), Yaml::parse(<<<EOF
621+
test: >
622+
<h2>A heading</h2>
623+
624+
<ul>
625+
<li>a list</li>
626+
<li>may be a good example</li>
627+
</ul>
628+
EOF
629+
));
630+
631+
$this->assertEquals(array('test' => <<<EOT
632+
<h2> 3 < 4 </h2>
633+
EOT
634+
), Yaml::parse(<<<EOF
635+
test: >
636+
<h2> 3 < 4 </h2>
637+
EOF
638+
));
639+
640+
$this->assertEquals(array('test' => <<<EOT
641+
<h2> 4 > 3 </h2>
642+
EOT
643+
), Yaml::parse(<<<EOF
644+
test: >
645+
<h2> 4 > 3 </h2>
646+
EOF
647+
));
648+
649+
}
614650
}
615651

616652
class B

0 commit comments

Comments
 (0)
0