Fix words with WWW in them being autolinked.

Don't autolink words that don't have `www.` in them.

Fixes #5968
This commit is contained in:
mark_story 2015-02-25 20:52:35 -05:00
parent ef820964e5
commit ea79cf5d13
2 changed files with 5 additions and 1 deletions

View file

@ -117,6 +117,10 @@ class TextHelperTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testAutoLink() { public function testAutoLink() {
$text = 'The AWWWARD show happened today';
$result = $this->Text->autoLink($text);
$this->assertEquals($text, $result);
$text = 'This is a test text'; $text = 'This is a test text';
$expected = 'This is a test text'; $expected = 'This is a test text';
$result = $this->Text->autoLink($text); $result = $this->Text->autoLink($text);

View file

@ -114,7 +114,7 @@ class TextHelper extends AppHelper {
$text $text
); );
$text = preg_replace_callback( $text = preg_replace_callback(
'#(?<!href="|">)(?<!\b[[:punct:]])(?<!http://|https://|ftp://|nntp://|//)www.[^\n\%\ <]+[^<\n\%\,\.\ <](?<!\))#i', '#(?<!href="|">)(?<!\b[[:punct:]])(?<!http://|https://|ftp://|nntp://|//)www\.[^\n\%\ <]+[^<\n\%\,\.\ <](?<!\))#i',
array(&$this, '_insertPlaceHolder'), array(&$this, '_insertPlaceHolder'),
$text $text
); );