Ticket #10990: make_clickable_end_chars.10990.3.diff

File make_clickable_end_chars.10990.3.diff, 1.5 KB (added by filosofo, 4 years ago)
Line 
1Index: wp-includes/formatting.php
2===================================================================
3--- wp-includes/formatting.php  (revision 12083)
4+++ wp-includes/formatting.php  (working copy)
5@@ -1186,17 +1186,11 @@
6 function _make_url_clickable_cb($matches) {
7        $url = $matches[2];
8 
9-       $after = '';
10-       if ( preg_match( '|(.+?)([).,;:]*)$|', $url, $split ) ) {
11-               $url = $split[1];
12-               $after = $split[2];
13-       }
14-
15        $url = esc_url($url);
16        if ( empty($url) )
17                return $matches[0];
18 
19-       return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>$after";
20+       return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>";
21 }
22 
23 /**
24@@ -1258,7 +1252,7 @@
25 function make_clickable($ret) {
26        $ret = ' ' . $ret;
27        // in testing, using arrays here was found to be faster
28-       $ret = preg_replace_callback('#(?<=[\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#$%&~/\-=?@\[\](+]|[.,;:](?![\s<])|(?(1)\)(?![\s<])|\)))+)#is', '_make_url_clickable_cb', $ret);
29+       $ret = preg_replace_callback('#(?<=[\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#$%&~/=?@\[\](+-]|[.,;:](?![\s<]|(\))?([\s]|$))|(?(1)\)(?![\s<]|$)|\)))+)#is', '_make_url_clickable_cb', $ret);
30        $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret);
31        $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret);
32        // this one is not in an array because we need it to run last, for cleanup of accidental links within links