From f7f81f534434bb254a2fb4265a3bd77fcf7dc482 Mon Sep 17 00:00:00 2001 From: Luis Calvo Date: Fri, 21 Jun 2019 16:26:13 +0200 Subject: [PATCH] Custom fields url improved --- pandora_console/include/functions_ui.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index c81148b9c9..c6806da2c8 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -48,15 +48,18 @@ if (isset($config['homedir'])) { */ function ui_bbcode_to_html($text, $allowed_tags=['[url]']) { - $return = $text; + $return = io_safe_output($text); if (array_search('[url]', $allowed_tags) !== false) { - $return = preg_replace( - '/\[url=([^\]]*)\]/', - '', - $return - ); - $return = str_replace('[/url]', '', $return); + // If link hasn't http, add it. + if (preg_match('/https?:\/\//', $return)) { + $html_bbcode = '$2'; + } else { + $html_bbcode = '$2'; + } + + // Replace bbcode format [url=www.example.org] String [/url] with or without http and slashes + $return = preg_replace('/\[url(?|](((?:https?:\/\/)?[^[]+))|(?:=[\'"]?((?:https?:\/\/)?[^]]+?)[\'"]?)](.+?))\[\/url]/', $html_bbcode, $return); } return $return;