From 27699d1f1252ff634b0b578959b2be3e05315862 Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 25 Apr 2014 22:24:25 +0530 Subject: [PATCH] Fix auto linking urls with subdomain with underscore. Closes #3392 --- lib/Cake/Test/Case/View/Helper/TextHelperTest.php | 4 ++++ lib/Cake/View/Helper/TextHelper.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/View/Helper/TextHelperTest.php b/lib/Cake/Test/Case/View/Helper/TextHelperTest.php index d38d60529..9a3eba7cb 100644 --- a/lib/Cake/Test/Case/View/Helper/TextHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/TextHelperTest.php @@ -265,6 +265,10 @@ class TextHelperTest extends CakeTestCase { 'Text with a url http://www.not--work.com and more', 'Text with a url http://www.not--work.com and more', ), + array( + 'Text with a url http://www.sub_domain.domain.pl and more', + 'Text with a url http://www.sub_domain.domain.pl and more', + ), array( 'Text with a partial www.küchenschöhn-not-working.de URL', 'Text with a partial www.küchenschöhn-not-working.de URL' diff --git a/lib/Cake/View/Helper/TextHelper.php b/lib/Cake/View/Helper/TextHelper.php index 451aa17b6..17ed5a4eb 100644 --- a/lib/Cake/View/Helper/TextHelper.php +++ b/lib/Cake/View/Helper/TextHelper.php @@ -104,7 +104,7 @@ class TextHelper extends AppHelper { $this->_placeholders = array(); $options += array('escape' => true); - $pattern = '#(?)((?:https?|ftp|nntp)://[\p{L}0-9.\-:]+(?:[/?][^\s<]*)?)#ui'; + $pattern = '#(?)((?:https?|ftp|nntp)://[\p{L}0-9.\-_:]+(?:[/?][^\s<]*)?)#ui'; $text = preg_replace_callback( $pattern, array(&$this, '_insertPlaceHolder'),