WordPress.org

Make WordPress Core

Ticket #10990: make_clickable_end_chars.10990.diff

File make_clickable_end_chars.10990.diff, 1.5 KB (added by filosofo, 5 years ago)
  • wp-includes/formatting.php

     
    11861186function _make_url_clickable_cb($matches) { 
    11871187        $url = $matches[2]; 
    11881188 
    1189         $after = ''; 
    1190         if ( preg_match( '|(.+?)([).,;:]*)$|', $url, $split ) ) { 
    1191                 $url = $split[1]; 
    1192                 $after = $split[2]; 
    1193         } 
    1194  
    11951189        $url = esc_url($url); 
    11961190        if ( empty($url) ) 
    11971191                return $matches[0]; 
    11981192 
    1199         return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>$after"; 
     1193        return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>"; 
    12001194} 
    12011195 
    12021196/** 
     
    12581252function make_clickable($ret) { 
    12591253        $ret = ' ' . $ret; 
    12601254        // in testing, using arrays here was found to be faster 
    1261         $ret = preg_replace_callback('#(?<=[\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#$%&~/\-=?@\[\](+]|[.,;:](?![\s<])|(?(1)\)(?![\s<])|\)))+)#is', '_make_url_clickable_cb', $ret); 
     1255        $ret = preg_replace_callback('#(?<=[\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#$%&~/=?@\[\](+-]|[.,;:](?![\s<\)]|$)|(?(1)\)(?![\s<])|\)))+)#is', '_make_url_clickable_cb', $ret); 
    12621256        $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret); 
    12631257        $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret); 
    12641258        // this one is not in an array because we need it to run last, for cleanup of accidental links within links