Merge pull request #3395 from ADmad/2.4-autolinkurl

Fix auto linking urls with subdomain with underscore.

Fixes #3392
This commit is contained in:
Mark Story 2014-04-25 15:33:24 -04:00
commit 4a24d6ea31
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'),