mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge pull request #5890 from cakephp/issue-5889
Fix doubly linking URLs starting with //
This commit is contained in:
commit
c8ca7cbfd9
2 changed files with 5 additions and 1 deletions
|
@ -127,6 +127,10 @@ class TextHelperTest extends CakeTestCase {
|
|||
$expected = 'Text with a partial <a href="http://www.cakephp.org">www.cakephp.org</a> URL and <a href="mailto:test@cakephp\.org">test@cakephp\.org</a> email address';
|
||||
$this->assertRegExp('#^' . $expected . '$#', $result);
|
||||
|
||||
$text = 'Text with a partial <a href="//www.cakephp.org">link</a> link';
|
||||
$result = $this->Text->autoLink($text, array('escape' => false));
|
||||
$this->assertEquals($text, $result);
|
||||
|
||||
$text = 'This is a test text with URL http://www.cakephp.org';
|
||||
$expected = 'This is a test text with URL <a href="http://www.cakephp.org">http://www.cakephp.org</a>';
|
||||
$result = $this->Text->autoLink($text);
|
||||
|
|
|
@ -114,7 +114,7 @@ class TextHelper extends AppHelper {
|
|||
$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
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue