diff --git a/templates/email/html/default.php b/templates/email/html/default.php index 70a6cd4492..47421fde07 100644 --- a/templates/email/html/default.php +++ b/templates/email/html/default.php @@ -15,8 +15,11 @@ * @var string $content */ -$lines = explode("\n", $content); - -foreach ($lines as $line) : - echo '
' . $line . "
\n"; -endforeach; +// $content is plain text: blank lines separate paragraphs and single line breaks become= implode('
', array_map(h(...), preg_split('/(*BSR_ANYCRLF)\R/', $paragraph) ?: [])) ?>
First line
second line
Next paragraph
', + preg_replace('/>\s+', '><', trim($html)), + ); + } + + /** + * Test the content is escaped. + * + * @return void + */ + public function testHtmlEscapesContent(): void + { + $html = $this->renderHtml(' & more'); + + $this->assertStringContainsString('<script>alert("x")</script> & more', $html); + $this->assertStringNotContainsString('