summaryrefslogtreecommitdiff
path: root/inc/functions.php
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2012-01-06 06:34:21 +1100
committerMichael Save <savetheinternet@tinyboard.org>2012-01-06 06:34:21 +1100
commitf21577fa5a44358bb3784e9ede8b2d2ed01138f9 (patch)
tree600a665f254734fdbb118c62474ec9b7cd924db3 /inc/functions.php
parent1df801b4146bfdd82947ba444e2ac6a5e82477ec (diff)
do not count puncutation after links as part of the uRL
Diffstat (limited to 'inc/functions.php')
-rw-r--r--inc/functions.php17
1 files changed, 16 insertions, 1 deletions
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 '<a target="_blank" rel="nofollow" href="' . $url . '">' . $url . '</a>' . $after;
+ }
+
function markup(&$body, $track_cites = false) {
global $board, $config;
@@ -1298,7 +1313,7 @@
}
if($config['markup_urls']) {
- $body = preg_replace($config['url_regex'], "<a target=\"_blank\" rel=\"nofollow\" href=\"$0\">$0</a>", $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']);
}