Skip to content

Commit

Permalink
Fix words with WWW in them being autolinked.
Browse files Browse the repository at this point in the history
Don't autolink words that don't have `www.` in them.

Fixes #5968
  • Loading branch information
markstory committed Feb 26, 2015
1 parent ef82096 commit ea79cf5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/Cake/Test/Case/View/Helper/TextHelperTest.php
Expand Up @@ -117,6 +117,10 @@ public function testEngineOverride() {
* @return void
*/
public function testAutoLink() {
$text = 'The AWWWARD show happened today';
$result = $this->Text->autoLink($text);
$this->assertEquals($text, $result);

$text = 'This is a test text';
$expected = 'This is a test text';
$result = $this->Text->autoLink($text);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/View/Helper/TextHelper.php
Expand Up @@ -114,7 +114,7 @@ public function autoLinkUrls($text, $options = array()) {
$text
);
$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'),
$text
);
Expand Down

0 comments on commit ea79cf5

Please sign in to comment.