summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCraig Andrews <candrews@integralblue.com>2009-08-18 14:15:55 -0400
committerCraig Andrews <candrews@integralblue.com>2009-08-18 14:15:55 -0400
commitce004083d9c3c22cacaf059aae3cfd725fda6936 (patch)
treee6a23d8e472d423980476176a6e1baefcb929165 /lib
parent84227dd4e1f5e776d56c759297605027a5824c57 (diff)
IPv4 and IPv6 addresses are picked up in URLs
Added ".onion" as a possible TLD
Diffstat (limited to 'lib')
-rw-r--r--lib/util.php28
1 files changed, 24 insertions, 4 deletions
diff --git a/lib/util.php b/lib/util.php
index c8e318efe..5ecee6915 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -417,11 +417,31 @@ function common_replace_urls_callback($text, $callback, $notice_id = null) {
'(?:https?|ftps?|mms|rtsp|gopher|news|nntp|telnet|wais|file|prospero|webcal|irc)://'.
'|'.
'(?:mailto|aim|tel|xmpp):'.
+ ')?'.
+ '('.
+ '(?:(?: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
+ '|(?:'.
+ '([0-9a-f]{1,4}:){1,1}(:[0-9a-f]{1,4}){1,6}|'. //IPv6
+ '([0-9a-f]{1,4}:){1,2}(:[0-9a-f]{1,4}){1,5}|'.
+ '([0-9a-f]{1,4}:){1,3}(:[0-9a-f]{1,4}){1,4}|'.
+ '([0-9a-f]{1,4}:){1,4}(:[0-9a-f]{1,4}){1,3}|'.
+ '([0-9a-f]{1,4}:){1,5}(:[0-9a-f]{1,4}){1,2}|'.
+ '([0-9a-f]{1,4}:){1,6}(:[0-9a-f]{1,4}){1,1}|'.
+ '(([0-9a-f]{1,4}:){1,7}|:):|'.
+ ':(:[0-9a-f]{1,4}){1,7}|'.
+ '((([0-9a-f]{1,4}:){6})(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3})|'.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