Fix autoLinkEmail() not working when emails are adjacent to HTML.

When an email address is adjacent to HTML it should be autolinked
correctly.

Refs #3656
This commit is contained in:
mark_story 2014-06-16 21:48:30 -04:00
parent 74d8e9ea40
commit 9136f63874
2 changed files with 12 additions and 1 deletions

View file

@ -415,6 +415,17 @@ class TextHelperTest extends CakeTestCase {
array('class' => 'link'),
),
array(
'<p>mark@example.com</p>',
'<p><a href="mailto:mark@example.com">mark@example.com</a></p>',
array('escape' => false)
),
array(
'Some&nbsp;mark@example.com&nbsp;Text',
'Some&nbsp;<a href="mailto:mark@example.com">mark@example.com</a>&nbsp;Text',
array('escape' => false)
),
);
}

View file

@ -190,7 +190,7 @@ class TextHelper extends AppHelper {
$atom = '[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]';
$text = preg_replace_callback(
'/(?<=\s|^|\()(' . $atom . '*(?:\.' . $atom . '+)*@[\p{L}0-9-]+(?:\.[\p{L}0-9-]+)+)/ui',
'/(?<=\s|^|\(|\>|\;)(' . $atom . '*(?:\.' . $atom . '+)*@[\p{L}0-9-]+(?:\.[\p{L}0-9-]+)+)/ui',
array(&$this, '_insertPlaceholder'),
$text
);