Skip to content

Commit 5e50986

Browse files
committed
Fix Issue with email linking between () #5
1 parent bcb4e7b commit 5e50986

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Autolink.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function convertEmail($text, $attribs = array())
103103
{
104104
$self = $this;
105105

106-
$regex = "/(([a-zA-Z]*=\")*\S+@\S+\.\S+)/";
106+
$regex = "/(([a-zA-Z]*=\")*[a-zA-Z0-9!#$%&'*+-\/=?^_`{|}~:]+@[a-zA-Z0-9!#$%&'*+-\/=?^_`{|}~\">]+)/";
107107

108108
return preg_replace_callback(
109109
$regex,

test/AutolinkTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public function testConvertEmail()
258258
<div data-target="sakura@flower.com" wdith="100"/></div>
259259
<div data-target="mailto:sakura@flower.com" wdith="100"/></div>
260260
261-
and emails are coming in between(salsan@lt.com).
261+
and emails are coming in between(sakura@flower.com).
262262
TEXT;
263263

264264
$html = <<<HTML
@@ -273,6 +273,7 @@ public function testConvertEmail()
273273
<div data-target="sakura@flower.com" wdith="100"/></div>
274274
<div data-target="mailto:sakura@flower.com" wdith="100"/></div>
275275
276+
and emails are coming in between(<a href="mailto:sakura@flower.com">sakura@flower.com</a>).
276277
HTML;
277278

278279

0 commit comments

Comments
 (0)