diff options
| author | Michael Save <savetheinternet@tinyboard.org> | 2012-03-11 11:29:33 +1100 |
|---|---|---|
| committer | Michael Save <savetheinternet@tinyboard.org> | 2012-03-11 11:29:33 +1100 |
| commit | 32c8791ff8223e04d73e52106eb5a8de2ca871c5 (patch) | |
| tree | 0bf881b7d20c32f124acbbf2c5514fc59ed3f6b0 /inc | |
| parent | 842b4312c97bf881dd8274ae7fb656a2c104783f (diff) | |
URL regex fix
Diffstat (limited to 'inc')
| -rw-r--r-- | inc/functions.php | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/inc/functions.php b/inc/functions.php index f1c233cf..fb701037 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1334,13 +1334,8 @@ function markup_url($matches) { global $markup_urls; - $url = $matches[0]; - $after = ''; - - if(preg_match('/([)\]][.,!;]?|[.,!;][)\]]?)$/', $url, $match)) { - $url = substr($url, 0, 0 - strlen($match[1])); - $after = $match[1]; - } + $url = $matches[1]; + $after = $matches[2]; $markup_urls[] = $url; @@ -1376,7 +1371,13 @@ if($config['markup_urls']) { $markup_urls = Array(); - $body = preg_replace_callback($config['url_regex'], 'markup_url', $body, -1, $num_links); + $body = preg_replace_callback( + '/((?:https?:\/\/|ftp:\/\/|irc:\/\/)[^\s<>()"]*?(?:\([^\s<>()"]*?\)[^\s<>()"]*?)*)((?:\s|<|>|"|\.||\]|!|\?|,|,|")*(?:[\s<>()"]|$))/', + 'markup_url', + $body, + -1, + $num_links); + if($num_links > $config['max_links']) error($config['error']['toomanylinks']); } |
