Browse Source

allow more punctuation after URLs

pull/40/head
Michael Save 12 years ago
parent
commit
5510be3ded
  1. 11
      inc/functions.php

11
inc/functions.php

@ -1306,15 +1306,12 @@
} }
function markup_url($matches) { function markup_url($matches) {
$strip_from_end = Array('.', ',', ')');
$url = $matches[0]; $url = $matches[0];
$after = ''; $after = '';
$last = $url[strlen($url)-1]; if(preg_match('/([)\]][.,!;]?|[.,!;][)\]]?)$/', $url, $match)) {
if(in_array($last, $strip_from_end)) { $url = substr($url, 0, 0 - strlen($match[1]));
$after = $last; $after = $match[1];
$url = substr($url, 0, -1);
} }
return '<a target="_blank" rel="nofollow" href="' . $url . '">' . $url . '</a>' . $after; return '<a target="_blank" rel="nofollow" href="' . $url . '">' . $url . '</a>' . $after;
@ -1336,7 +1333,7 @@
$body = preg_replace_callback($config['url_regex'], 'markup_url', $body, -1, $num_links); $body = preg_replace_callback($config['url_regex'], 'markup_url', $body, -1, $num_links);
if($num_links > $config['max_links']) if($num_links > $config['max_links'])
error($config['error']['toomanylinks']); error($config['error']['toomanylinks']);
} }//exit;
if($config['auto_unicode']) { if($config['auto_unicode']) {
$body = str_replace('...', '&hellip;', $body); $body = str_replace('...', '&hellip;', $body);

Loading…
Cancel
Save