Browse Source

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
mark_story 12 years ago
parent
commit
7c66d0db50
1 changed files with 1 additions and 1 deletions
  1. 1 1
      lib/Cake/View/Helper/TextHelper.php

+ 1 - 1
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
 		);