Fix autoLink() when URLs contain email addresses.

Add whitespace lookbehind to ensure the email address is preceded by
whitespace, this obviously means that emails starting with word/symbols
are not detected, however those symbols are generally valid in an email
address anyways, and will form the local part.

Fixes #2403
This commit is contained in:
mark_story 2013-11-29 22:22:38 -05:00
parent bbe4c659aa
commit 7c66d0db50

View file

@ -187,7 +187,7 @@ class TextHelper extends AppHelper {
$atom = '[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]';
$text = preg_replace_callback(
'/(' . $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
);