From 54e172b1296f12a2c2c3b6b569c96e6a86d78f3f Mon Sep 17 00:00:00 2001 From: Rob McVey Date: Fri, 2 Jan 2015 15:15:23 +0000 Subject: [PATCH] Regex modified to to not capture brackets Modified the existing regex from th TLD onwards Credit to @gruber for the regex info https://gist.github.com/gruber/249502 --- lib/Cake/View/Helper/TextHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/View/Helper/TextHelper.php b/lib/Cake/View/Helper/TextHelper.php index 6e9684765..92d30ace6 100644 --- a/lib/Cake/View/Helper/TextHelper.php +++ b/lib/Cake/View/Helper/TextHelper.php @@ -107,7 +107,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()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))#i'; $text = preg_replace_callback( $pattern, array(&$this, '_insertPlaceHolder'),