]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] lua_scanners - fix small errors
authorCarsten Rosenberg <c.rosenberg@heinlein-support.de>
Fri, 27 Sep 2019 12:06:41 +0000 (14:06 +0200)
committerCarsten Rosenberg <c.rosenberg@heinlein-support.de>
Fri, 27 Sep 2019 12:06:41 +0000 (14:06 +0200)
lualib/lua_scanners/common.lua
lualib/lua_scanners/icap.lua

index dcd31db30ba019da175c2b52cdeb181bf0cda4b4..64f67dcc8bb3e57887183329c9bdba53f7b4ab54 100644 (file)
@@ -207,7 +207,7 @@ local function check_cache(task, digest, rule, fn)
       if err then
         rspamd_logger.errx(task, 'got error checking cache: %s', err)
       end
-      fn()
+      return true
     end
   end
 
index c7b495c294b39e50f1d6733a5713a0d8ab50e5a9..d43ba4f783e314f751034946ba486ff5db654592 100644 (file)
@@ -243,20 +243,29 @@ local function icap_check(task, content, digest, rule)
             table.insert(threat_string, icap_headers['X-Virus-ID'])
           end
         elseif icap_headers['X-FSecure-Scan-Result'] ~= nil and icap_headers['X-FSecure-Scan-Result'] ~= "clean" then
+
+          local infected_filename = ""
+          local infection_name = "-unknown-"
+
+          if icap_headers['X-FSecure-Infected-Filename'] ~= nil then
+            infected_filename = string.gsub(icap_headers['X-FSecure-Infected-Filename'], '[%s"]', '')
+          end
+          if icap_headers['X-FSecure-Infection-Name'] ~= nil then
+            infection_name = string.gsub(icap_headers['X-FSecure-Infection-Name'], '[%s"]', '')
+          end
+
           lua_util.debugm(rule.name, task,
               '%s: icap X-FSecure-Infection-Name (X-FSecure-Infected-Filename): %s (%s)',
-              rule.log_prefix, string.gsub(icap_headers['X-FSecure-Infection-Name'], '[%s"]', ''),
-              string.gsub(icap_headers['X-FSecure-Infected-Filename:'], '[%s"]', ''))
+              rule.log_prefix, infection_name, infected_filename)
 
-          if string.find(icap_headers['X-FSecure-Infection-Name'], ', ') then
-            local vnames = rspamd_str_split(string.gsub(icap_headers['X-FSecure-Infection-Name'], '[%s"]', '')
-              , ',') or {}
+          if string.find(infection_name, ', ') then
+            local vnames = rspamd_str_split(infection_name, ',') or {}
 
             for _,v in ipairs(vnames) do
               table.insert(threat_string, v)
             end
           else
-            table.insert(threat_string, string.gsub(icap_headers['X-FSecure-Infection-Name'], '[%s"]', ''))
+            table.insert(threat_string, infection_name)
           end
         end
         if #threat_string > 0 then