mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge pull request #477 from krolow/ticket-2574
fixing regex of autoLinks to work with urls that have www
This commit is contained in:
commit
ba249aeff6
2 changed files with 23 additions and 3 deletions
|
@ -336,6 +336,26 @@ podeís adquirirla.</span></p>
|
||||||
$expected = 'Text with a partial <iframe src="http://www.cakephp.org" /> link';
|
$expected = 'Text with a partial <iframe src="http://www.cakephp.org" /> link';
|
||||||
$result = $this->Text->autoLinkUrls($text, array('escape' => false));
|
$result = $this->Text->autoLinkUrls($text, array('escape' => false));
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
|
$text = 'Text with a url <a href="http://www.not-working-www.com">www.not-working-www.com</a> and more';
|
||||||
|
$expected = 'Text with a url <a href="http://www.not-working-www.com">www.not-working-www.com</a> and more';
|
||||||
|
$result = $this->Text->autoLinkUrls($text);
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
|
$text = 'Text with a url www.not-working-www.com and more';
|
||||||
|
$expected = 'Text with a url <a href="http://www.not-working-www.com">www.not-working-www.com</a> and more';
|
||||||
|
$result = $this->Text->autoLinkUrls($text);
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
|
$text = 'Text with a url http://www.not-working-www.com and more';
|
||||||
|
$expected = 'Text with a url <a href="http://www.not-working-www.com">http://www.not-working-www.com</a> and more';
|
||||||
|
$result = $this->Text->autoLinkUrls($text);
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
|
$text = 'Text with a url http://www.www.not-working-www.com and more';
|
||||||
|
$expected = 'Text with a url <a href="http://www.www.not-working-www.com">http://www.www.not-working-www.com</a> and more';
|
||||||
|
$result = $this->Text->autoLinkUrls($text);
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -121,7 +121,7 @@ class TextHelper extends AppHelper {
|
||||||
$text
|
$text
|
||||||
);
|
);
|
||||||
return preg_replace_callback(
|
return preg_replace_callback(
|
||||||
'#(?<!href="|">)(?<!http://|https://|ftp://|nntp://)(www\.[^\n\%\ <]+[^<\n\%\,\.\ <])(?<!\))#i',
|
'#(?<!href="|">)(?<!\b[[:punct:]])(?<!http://|https://|ftp://|nntp://)www.[^\n\%\ <]+[^<\n\%\,\.\ <](?<!\))#i',
|
||||||
array(&$this, '_linkUrls'),
|
array(&$this, '_linkUrls'),
|
||||||
$text
|
$text
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue