Implement alerts via email

Closes #272
This commit is contained in:
emanuele-f 2018-04-03 20:49:43 +02:00
parent 9889c291cc
commit 0f5d76ca74
14 changed files with 284 additions and 31 deletions

View file

@ -593,7 +593,22 @@ network_alert_functions_description = {
function noHtml(s)
if s == nil then return nil end
return s:gsub("<.->(.-)</.->","%1"):gsub("^%s*(.-)%s*$", "%1")
local cleaned = s:gsub("<[aA].->(.-)</[aA]>","%1")
:gsub("<[iI].->(.-)</[iI]>","%1")
:gsub("<.->(.-)</.->","%1") -- note: this does not handle nested tags
:gsub("^%s*(.-)%s*$", "%1")
return cleaned
end
function unescapeHtmlEntities(str)
str = string.gsub( str, '&lt;', '<' )
str = string.gsub( str, '&gt;', '>' )
str = string.gsub( str, '&quot;', '"' )
str = string.gsub( str, '&apos;', "'" )
str = string.gsub( str, '&#(%d+);', function(n) return string.char(n) end )
str = string.gsub( str, '&#x(%d+);', function(n) return string.char(tonumber(n,16)) end )
str = string.gsub( str, '&amp;', '&' ) -- Be sure to do this after all others
return str
end
function alertSeverityLabel(v, nohtml)