mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
commit
9553c029c4
2 changed files with 26 additions and 1 deletions
|
@ -146,6 +146,31 @@ class TextHelperTest extends CakeTestCase {
|
|||
$expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>(and some more text)';
|
||||
$result = $this->Text->autoLink($text);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$text = 'This is a test text with URL (http://www.cakephp.org/page/4) in brackets';
|
||||
$expected = 'This is a test text with URL (<a href="http://www.cakephp.org/page/4">http://www.cakephp.org/page/4</a>) in brackets';
|
||||
$result = $this->Text->autoLink($text);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$text = 'This is a test text with URL [http://www.cakephp.org/page/4] in square brackets';
|
||||
$expected = 'This is a test text with URL [<a href="http://www.cakephp.org/page/4">http://www.cakephp.org/page/4</a>] in square brackets';
|
||||
$result = $this->Text->autoLink($text);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$text = 'This is a test text with URL [http://www.example.com?aParam[]=value1&aParam[]=value2&aParam[]=value3] in square brackets';
|
||||
$expected = 'This is a test text with URL [<a href="http://www.example.com?aParam[]=value1&aParam[]=value2&aParam[]=value3">http://www.example.com?aParam[]=value1&aParam[]=value2&aParam[]=value3</a>] in square brackets';
|
||||
$result = $this->Text->autoLink($text);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$text = 'This is a test text with URL ;http://www.cakephp.org/page/4; semi-colon';
|
||||
$expected = 'This is a test text with URL ;<a href="http://www.cakephp.org/page/4">http://www.cakephp.org/page/4</a>; semi-colon';
|
||||
$result = $this->Text->autoLink($text);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$text = 'This is a test text with URL (http://www.cakephp.org/page/4/other(thing)) brackets';
|
||||
$expected = 'This is a test text with URL (<a href="http://www.cakephp.org/page/4/other(thing)">http://www.cakephp.org/page/4/other(thing)</a>) brackets';
|
||||
$result = $this->Text->autoLink($text);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -107,7 +107,7 @@ class TextHelper extends AppHelper {
|
|||
$this->_placeholders = array();
|
||||
$options += array('escape' => true);
|
||||
|
||||
$pattern = '#(?<!href="|src="|">)((?:https?|ftp|nntp)://[\p{L}0-9.\-_:]+(?:[/?][^\s<]*)?)#ui';
|
||||
$pattern = '#(?<!href="|src="|">)((?:https?|ftp|nntp)://[\p{L}0-9.\-_:]+(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))#i';
|
||||
$text = preg_replace_callback(
|
||||
$pattern,
|
||||
array(&$this, '_insertPlaceHolder'),
|
||||
|
|
Loading…
Reference in a new issue