From a4fddc28254a03dd95e5f8ea395723e17d2f24a8 Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Thu, 22 Oct 2009 18:46:27 +0000 Subject: [PATCH] Ensure that trailing ) in urls are included in the link when it looks appropriate. Fixes #10990 props filosofo. git-svn-id: https://develop.svn.wordpress.org/trunk@12088 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/formatting.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index b9eae6b5fc..75dc5adb59 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -1232,17 +1232,11 @@ function antispambot($emailaddy, $mailto=0) { function _make_url_clickable_cb($matches) { $url = $matches[2]; - $after = ''; - if ( preg_match( '|(.+?)([).,;:]*)$|', $url, $split ) ) { - $url = $split[1]; - $after = $split[2]; - } - $url = esc_url($url); if ( empty($url) ) return $matches[0]; - return $matches[1] . "$url$after"; + return $matches[1] . "$url"; } /** @@ -1304,7 +1298,7 @@ function _make_email_clickable_cb($matches) { function make_clickable($ret) { $ret = ' ' . $ret; // in testing, using arrays here was found to be faster - $ret = preg_replace_callback('#(?<=[\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#$%&~/\-=?@\[\](+]|[.,;:](?![\s<])|(?(1)\)(?![\s<])|\)))+)#is', '_make_url_clickable_cb', $ret); + $ret = preg_replace_callback('#(?<=[\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#$%&~/=?@\[\](+-]|[.,;:](?![\s<]|(\))?([\s]|$))|(?(1)\)(?![\s<]|$)|\)))+)#is', '_make_url_clickable_cb', $ret); $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret); $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret); // this one is not in an array because we need it to run last, for cleanup of accidental links within links