diff --git a/include/bbcode.php b/include/bbcode.php
index d891f23da..8969b35e1 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -170,6 +170,36 @@ function cleancss($input) {
return $cleaned;
}
+function bb_style_url($match) {
+ $url = $match[1];
+
+ $parts = parse_url($url);
+ if (!isset($parts['scheme'])) {
+ return $url;
+ }
+
+ $styled_url = $url;
+
+ $scheme = $parts['scheme'].'://';
+ $styled_url = str_replace($scheme, '', $styled_url);
+
+ $html = ''.
+ '%s';
+
+ if (strlen($styled_url) > 30) {
+ $html .= '%s'.
+ '%s';
+
+ $ellipsis = substr($styled_url, 0, 30);
+ $rest = substr($styled_url, 30);
+ return sprintf($html, $url, $scheme, $ellipsis, $rest);
+ } else {
+ $html .= '%s';
+ return sprintf($html, $url, $scheme, $styled_url);
+ }
+}
+
+
function stripcode_br_cb($s) {
return '[code]' . str_replace('
', '', $s[1]) . '[/code]';
}
@@ -956,6 +986,10 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
$Text = preg_replace("/([#])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
'$1$3', $Text);
+ if ($simplehtml == 7) {
+ $Text = preg_replace_callback("/\[url\]([$URLSearchString]*)\[\/url\]/ism", 'bb_style_url', $Text);
+ }
+
$Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '$1', $Text);
$Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$2', $Text);
//$Text = preg_replace("/\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[\/url\]/ism", '$2', $Text);