We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 579a41b5 authored by Craig Andrews's avatar Craig Andrews

Improve url finding more. Properly end urls when a space is caught.

parent 0615fda2
......@@ -412,13 +412,15 @@ function common_render_text($text)
function common_replace_urls_callback($text, $callback, $notice_id = null) {
// Start off with a regex
$regex = '#'.
'(?:^|[\s\(\)\[\]\{\}]+)('.
'(?:^|[\s\(\)\[\]\{\}]+)'.
'('.
'(?:'.
'(?:'. //Known protocols
'(?:'.
'(?:https?|ftps?|mms|rtsp|gopher|news|nntp|telnet|wais|file|prospero|webcal|irc)://'.
'|'.
'(?:mailto|aim|tel|xmpp):'.
')[^\s\(\)\[\]\{\}]+'.
')[^\s\/]+'.
')'.
'|(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'. //IPv4
'|(?:'. //IPv6
......@@ -442,7 +444,12 @@ function common_replace_urls_callback($text, $callback, $notice_id = null) {
')|(?:'. //DNS
'\S+\.(?:museum|travel|onion|local|[a-z]{2,4})'.
')'.
'([^\s\(\)\[\]\{\}]*)'.
')'.
'(?:'.
'$|(?:'.
'/[^\s\(\)\[\]\{\}]*'.
')'.
')'.
')'.
'#ix';
return preg_replace_callback($regex, curry(callback_helper,$callback,$notice_id) ,$text);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment