From cbf4aa7f8c3a55bc08cfb2e437916527b5d856b4 Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Fri, 21 Mar 2008 16:29:59 +0000 Subject: [PATCH] make_clickable() trailing punctuation fixes from neodude. fixes #5081 git-svn-id: https://develop.svn.wordpress.org/trunk@7452 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/formatting.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 823ebde0a3..36393be453 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -631,21 +631,32 @@ function antispambot($emailaddy, $mailto=0) { } function _make_url_clickable_cb($matches) { + $ret = ''; $url = $matches[2]; $url = clean_url($url); if ( empty($url) ) return $matches[0]; - return $matches[1] . "$url"; + // removed trailing [.,;:] from URL + if ( in_array(substr($url, -1), array('.', ',', ';', ':')) === true ) { + $ret = substr($url, -1); + $url = substr($url, 0, strlen($url)-1); + } + return $matches[1] . "$url" . $ret; } function _make_web_ftp_clickable_cb($matches) { + $ret = ''; $dest = $matches[2]; $dest = 'http://' . $dest; $dest = clean_url($dest); if ( empty($dest) ) return $matches[0]; - - return $matches[1] . "$dest"; + // removed trailing [,;:] from URL + if ( in_array(substr($dest, -1), array('.', ',', ';', ':')) === true ) { + $ret = substr($dest, -1); + $dest = substr($dest, 0, strlen($dest)-1); + } + return $matches[1] . "$dest" . $ret; } function _make_email_clickable_cb($matches) {