Skip to content

Commit

Permalink
Merge pull request #3395 from ADmad/2.4-autolinkurl
Browse files Browse the repository at this point in the history
Fix auto linking urls with subdomain with underscore.

Fixes #3392
  • Loading branch information
markstory committed Apr 25, 2014
2 parents 00be120 + 27699d1 commit 4a24d6e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/Cake/Test/Case/View/Helper/TextHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ public static function autoLinkProvider() {
'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'
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/View/Helper/TextHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function autoLinkUrls($text, $options = array()) {
$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'),
Expand Down

0 comments on commit 4a24d6e

Please sign in to comment.