From bd9255c5285f8e2c9fb46ad225aa9ac03ae93d3b Mon Sep 17 00:00:00 2001 From: Eloy Lafuente Date: Fri, 8 Jan 2010 17:20:56 +0000 Subject: [PATCH] MDL-21168 convert_urls_into_links() - changed solution to avoid linking inside tags by negative look-behind assertion of =" string ; merged from 19_STABLE --- lib/weblib.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index c9b0700759..1f09ce182b 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -1727,8 +1727,8 @@ function convert_urls_into_links(&$text) { // //<a href="blah"> //<a href="blah"> - $filterignoretagsopen = array(']+?>', ']+?>'); - $filterignoretagsclose = array('',''); + $filterignoretagsopen = array(']+?>'); + $filterignoretagsclose = array(''); filter_save_ignore_tags($text,$filterignoretagsopen,$filterignoretagsclose,$ignoretags); // Check if we support unicode modifiers in regular expressions. Cache it. @@ -1743,14 +1743,14 @@ function convert_urls_into_links(&$text) { } if ($unicoderegexp) { //We can use unicode modifiers - $text = preg_replace('#(((http(s?))://)(((([\pLl0-9]([\pLl0-9]|-)*[\pLl0-9]|[\pLl0-9])\.)+([\pLl]([\pLl0-9]|-)*[\pLl0-9]|[\pLl]))|(([0-9]{1,3}\.){3}[0-9]{1,3}))(:[\pL0-9]*)?(/([\pLl0-9\.!$&\'\(\)*+,;=_~:@-]|%[a-fA-F0-9]{2})*)*(\?[\pLl0-9\.!$&\'\(\)*+,;=_~:@/?-]*)?(\#[\pLl0-9\.!$&\'\(\)*+,;=_~:@/?-]*)?(?\\1', $text); - $text = preg_replace('#((www\.([\pLl0-9]([\pLl0-9]|-)*[\pLl0-9]|[\pLl0-9])\.)+([\pLl]([\pLl0-9]|-)*[\pLl0-9]|[\pLl])(:[\pL0-9]*)?(/([\pLl0-9\.!$&\'\(\)*+,;=_~:@-]|%[a-fA-F0-9]{2})*)*(\?[\pLl0-9\.!$&\'\(\)*+,;=_~:@/?-]*)?(\#[\pLl0-9\.!$&\'\(\)*+,;=_~:@/?-]*)?(?\\1', $text); } else { //We cannot use unicode modifiers - $text = preg_replace('#(((http(s?))://)(((([a-z0-9]([a-z0-9]|-)*[a-z0-9]|[a-z0-9])\.)+([a-z]([a-z0-9]|-)*[a-z0-9]|[a-z]))|(([0-9]{1,3}\.){3}[0-9]{1,3}))(:[a-zA-Z0-9]*)?(/([a-z0-9\.!$&\'\(\)*+,;=_~:@-]|%[a-f0-9]{2})*)*(\?[a-z0-9\.!$&\'\(\)*+,;=_~:@/?-]*)?(\#[a-z0-9\.!$&\'\(\)*+,;=_~:@/?-]*)?(?\\1', $text); - $text = preg_replace('#((www\.([a-z0-9]([a-z0-9]|-)*[a-z0-9]|[a-z0-9])\.)+([a-z]([a-z0-9]|-)*[a-z0-9]|[a-z])(:[a-zA-Z0-9]*)?(/([a-z0-9\.!$&\'\(\)*+,;=_~:@-]|%[a-f0-9]{2})*)*(\?[a-z0-9\.!$&\'\(\)*+,;=_~:@/?-]*)?(\#[a-z0-9\.!$&\'\(\)*+,;=_~:@/?-]*)?(?\\1', $text); } @@ -3355,4 +3355,4 @@ function print_password_policy(){ $message = '
 
'. get_string('informpasswordpolicy', 'auth', $message) . '
'; } return $message; -} \ No newline at end of file +} -- 2.39.5