Fix auto linking urls with subdomain with underscore.

Closes #3392
This commit is contained in:
ADmad 2014-04-25 22:24:25 +05:30
parent 00be120e7a
commit 27699d1f12
2 changed files with 5 additions and 1 deletions

View file

@ -265,6 +265,10 @@ class TextHelperTest extends CakeTestCase {
'Text with a url http://www.not--work.com and more',
'Text with a url <a href="http://www.not--work.com">http://www.not--work.com</a> and more',
),
array(
'Text with a url http://www.sub_domain.domain.pl and more',
'Text with a url <a href="http://www.sub_domain.domain.pl">http://www.sub_domain.domain.pl</a> and more',
),
array(
'Text with a partial www.küchenschöhn-not-working.de URL',
'Text with a partial <a href="http://www.küchenschöhn-not-working.de">www.küchenschöhn-not-working.de</a> URL'

View file

@ -104,7 +104,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<]*)?)#ui';
$text = preg_replace_callback(
$pattern,
array(&$this, '_insertPlaceHolder'),