Make WordPress Core

Ticket #5081: formatting.php.diff

File formatting.php.diff, 1.3 KB (added by neodude, 17 years ago)

removes [.,;:] from urls with a protocol, [,;:] from urls without a protocol

  • wp-includes/formatting.php

     
    631631}
    632632
    633633function _make_url_clickable_cb($matches) {
     634        $ret = '';
    634635        $url = $matches[2];
    635636        $url = clean_url($url);
    636637        if ( empty($url) )
    637638                return $matches[0];
    638         return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>";
     639        // removed trailing [.,;:] from URL
     640        if ( in_array(substr($url, -1), array('.', ',', ';', ':')) === true ) {
     641                $ret = substr($url, -1);
     642                $url = substr($url, 0, strlen($url)-1);
     643        }
     644        return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $ret;
    639645}
    640646
    641647function _make_web_ftp_clickable_cb($matches) {
     648        $ret = '';
    642649        $dest = $matches[2];
    643650        $dest = 'http://' . $dest;
    644651        $dest = clean_url($dest);
    645652        if ( empty($dest) )
    646653                return $matches[0];
    647 
    648         return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>";
     654        // removed trailing [,;:] from URL
     655        if ( in_array(substr($dest, -1), array(',', ';', ':')) === true ) {
     656                $ret = substr($dest, -1);
     657                $dest = substr($dest, 0, strlen($dest)-1);
     658        }
     659        return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>" . $ret;
    649660}
    650661
    651662function _make_email_clickable_cb($matches) {