Skip to content

Commit

Permalink
Messages: fixed regexp for propagating links [Closes #18]
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 6, 2015
1 parent 9d35f65 commit 622595a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Mail/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ protected function buildText($html)
$text = Strings::replace($html, [
'#<(style|script|head).*</\\1>#Uis' => '',
'#<t[dh][ >]#i' => ' $0',
'#<a [^>]*href=("|\')([^\\1]+)\\1[^>]*>(.*?)</a>#i' => '$3 &lt;$2&gt;',
'#<a [^>]*href=(?|"([^"]+)"|\'([^\']+)\')[^>]*>(.*?)</a>#i' => '$2 &lt;$1&gt;',
'#[\r\n]+#' => ' ',
'#<(/?p|/?h\d|li|br|/tr)[ >/]#i' => "\n$0",
]);
Expand Down
6 changes: 3 additions & 3 deletions tests/Mail/Mail.HtmlBodyAndLinks.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $mail->setFrom('John Doe <[email protected]>');
$mail->addTo('Lady Jane <[email protected]>');
$mail->setSubject('Hello Jane!');

$mail->setHTMLBody('<b><span>Příliš </span> <a href="http://green.example.com">žluťoučký</a>' .
$mail->setHTMLBody('<b><span>Příliš </span> <a href="http://green.example.com">žluťoučký</a> "' .
' <br><a href=\'http://horse.example.com\'>kůň</a></b>');

$mailer = new TestMailer();
Expand All @@ -40,13 +40,13 @@ Content-Type: multipart/alternative;
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Příliš žluťoučký <http://green.example.com>
Příliš žluťoučký <http://green.example.com> "
kůň <http://horse.example.com>
----------%S%
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<b><span>Příliš </span> <a href="http://green.example.com">žluťoučký</a> <br><a href='http://horse.example.com'>kůň</a></b>
<b><span>Příliš </span> <a href="http://green.example.com">žluťoučký</a> " <br><a href='http://horse.example.com'>kůň</a></b>
----------%S%--
EOD
, TestMailer::$output);

0 comments on commit 622595a

Please sign in to comment.