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

Appearance settings

Commit 9e6baee

Browse filesBrowse files
committed
Remove full head content in HTML to text converter
When extracting text from HTML part all the content between opening and closing tag should be removed
1 parent 426bf96 commit 9e6baee
Copy full SHA for 9e6baee

File tree

Expand file treeCollapse file tree

2 files changed

+18
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+18
-1
lines changed

‎src/Symfony/Bridge/Twig/Mime/BodyRenderer.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Mime/BodyRenderer.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ private function convertHtmlToText(string $html): string
7474
return $this->converter->convert($html);
7575
}
7676

77-
return strip_tags(preg_replace('{<(head|style)\b.*?</\1>}i', '', $html));
77+
return strip_tags(preg_replace('{<(head|style)\b.*?</\1>}is', '', $html));
7878
}
7979
}

‎src/Symfony/Bridge/Twig/Tests/Mime/BodyRendererTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Tests/Mime/BodyRendererTest.php
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,23 @@ public function testRenderHtmlOnly()
3737
$this->assertEquals(str_replace('=', '=3D', $html), $body->getParts()[1]->bodyToString());
3838
}
3939

40+
public function testRenderMultiLineHtmlOnly()
41+
{
42+
$html = <<<HTML
43+
<head>
44+
<style type="text/css">
45+
css
46+
</style>
47+
</head>
48+
<b>HTML</b>
49+
HTML;
50+
$email = $this->prepareEmail(null, $html);
51+
$body = $email->getBody();
52+
$this->assertInstanceOf(AlternativePart::class, $body);
53+
$this->assertEquals('HTML', str_replace(["\r", "\n"], '', $body->getParts()[0]->bodyToString()));
54+
$this->assertEquals(str_replace(['=', "\n"], ['=3D', "\r\n"], $html), $body->getParts()[1]->bodyToString());
55+
}
56+
4057
public function testRenderHtmlOnlyWithTextSet()
4158
{
4259
$email = $this->prepareEmail(null, '<b>HTML</b>');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.