mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-01 00:19:33 +00:00
Avoid adding duplicate applications with different letter case
Fix #2534
This commit is contained in:
parent
d5d551853c
commit
94b143c8a3
1 changed files with 13 additions and 4 deletions
|
|
@ -45,20 +45,29 @@ if (_POST["action"] == "add") or (_POST["action"] == "edit") then
|
|||
|
||||
-- Preliminary check
|
||||
local applications = interface.getnDPIProtocols()
|
||||
local app_exists = (applications[application] ~= nil)
|
||||
local lower_app = string.lower(application)
|
||||
local existing_app = nil
|
||||
|
||||
if((action == "edit") and (not app_exists)) then
|
||||
-- case insensitive search for applications
|
||||
for k in pairs(applications) do
|
||||
if string.lower(k) == lower_app then
|
||||
existing_app = k
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if((action == "edit") and (existing_app == nil)) then
|
||||
app_warnings[#app_warnings + 1] = {
|
||||
type = "danger",
|
||||
text = i18n("custom_categories.application_not_exists", {
|
||||
app = application,
|
||||
})
|
||||
}
|
||||
elseif((action == "add") and app_exists) then
|
||||
elseif((action == "add") and (existing_app ~= nil)) then
|
||||
app_warnings[#app_warnings + 1] = {
|
||||
type = "danger",
|
||||
text = i18n("custom_categories.application_exists", {
|
||||
app = application,
|
||||
app = existing_app,
|
||||
})
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue