Skip to content
Permalink
Browse files

uses nette/utils 3.1

  • Loading branch information
dg committed Jan 14, 2020
1 parent 003783c commit efc3de0c6a48e120144d3acac53880292c3f788f
Showing with 4 additions and 4 deletions.
  1. +1 −1 composer.json
  2. +3 −3 src/Mail/Message.php
@@ -17,7 +17,7 @@
"require": {
"php": ">=7.1",
"ext-iconv": "*",
"nette/utils": "^2.4 || ^3.0"
"nette/utils": "^3.1"
},
"require-dev": {
"nette/di": "^3.0.0",
@@ -227,7 +227,7 @@ public function setHtmlBody(string $html, string $basePath = null)

if ($this->getSubject() == null) { // intentionally ==
$html = Strings::replace($html, '#<title>(.+?)</title>#is', function (array $m): void {
$this->setSubject(html_entity_decode($m[1], ENT_QUOTES, 'UTF-8'));
$this->setSubject(Nette\Utils\Html::htmlToText($m[1]));
});
}

@@ -384,14 +384,14 @@ public function build()
*/
protected function buildText(string $html): string
{
$text = Strings::replace($html, [
$html = Strings::replace($html, [
'#<(style|script|head).*</\1>#Uis' => '',
'#<t[dh][ >]#i' => ' $0',
'#<a\s[^>]*href=(?|"([^"]+)"|\'([^\']+)\')[^>]*>(.*?)</a>#is' => '$2 &lt;$1&gt;',
'#[\r\n]+#' => ' ',
'#<(/?p|/?h\d|li|br|/tr)[ >/]#i' => "\n$0",
]);
$text = html_entity_decode(strip_tags($text), ENT_QUOTES, 'UTF-8');
$text = Nette\Utils\Html::htmlToText($html);
$text = Strings::replace($text, '#[ \t]+#', ' ');
return trim($text);
}

0 comments on commit efc3de0

Please sign in to comment.
You can’t perform that action at this time.