mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
Added invalid URL check
This commit is contained in:
parent
74fbc8860c
commit
4b7b74e7e5
1 changed files with 16 additions and 10 deletions
|
|
@ -1551,18 +1551,24 @@ end
|
|||
-- false otherwise
|
||||
-- @return A string containing the info field formatted
|
||||
function format_external_link(url, name, no_html, proto, i18n_key)
|
||||
local external_field = url
|
||||
proto = ternary(((proto) and (proto == 'http')), 'http', 'https')
|
||||
if(string.contains(url, " ")) then
|
||||
-- the string contains spaces, so it's not an URL
|
||||
-- Let's return it as it
|
||||
return(url)
|
||||
else
|
||||
local external_field = url
|
||||
proto = ternary(((proto) and (proto == 'http')), 'http', 'https')
|
||||
|
||||
if no_html == false then
|
||||
if not isEmptyString(url) and not string.find(url, '*') then
|
||||
if(i18n_key == nil) then i18n_key = "external_link_url" end
|
||||
url = string.gsub(url, " ", "") -- Clean the URL from spaces and %20, spaces in html
|
||||
external_field = i18n(i18n_key, { proto = proto, url = url, url_name = name})
|
||||
end
|
||||
end
|
||||
|
||||
if no_html == false then
|
||||
if not isEmptyString(url) and not string.find(url, '*') then
|
||||
if(i18n_key == nil) then i18n_key = "external_link_url" end
|
||||
url = string.gsub(url, " ", "") -- Clean the URL from spaces and %20, spaces in html
|
||||
external_field = i18n(i18n_key, { proto = proto, url = url, url_name = name})
|
||||
end
|
||||
return external_field
|
||||
end
|
||||
|
||||
return external_field
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue