From 7c66d0db50290313699f9442e4c8f2fe97146311 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 29 Nov 2013 22:22:38 -0500 Subject: [PATCH] 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 --- lib/Cake/View/Helper/TextHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/View/Helper/TextHelper.php b/lib/Cake/View/Helper/TextHelper.php index f40a93aaa..c418a54de 100644 --- a/lib/Cake/View/Helper/TextHelper.php +++ b/lib/Cake/View/Helper/TextHelper.php @@ -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 );