diff --git a/inc/functions.php b/inc/functions.php index e9b93d6e..4fae5f84 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1285,6 +1285,21 @@ return $body . "\n"; } + function markup_url($matches) { + $strip_from_end = Array('.', ',', ')'); + + $url = $matches[0]; + $after = ''; + + $last = $url[strlen($url)-1]; + if(in_array($last, $strip_from_end)) { + $after = $last; + $url = substr($url, 0, -1); + } + + return '' . $url . '' . $after; + } + function markup(&$body, $track_cites = false) { global $board, $config; @@ -1298,7 +1313,7 @@ } if($config['markup_urls']) { - $body = preg_replace($config['url_regex'], "$0", $body, -1, $num_links); + $body = preg_replace_callback($config['url_regex'], 'markup_url', $body, -1, $num_links); if($num_links > $config['max_links']) error($config['error']['toomanylinks']); }