]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix result parsing for SAVAPI
authorChristian Roessner <c@roessner-network-solutions.com>
Fri, 5 May 2017 10:00:25 +0000 (12:00 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Tue, 9 May 2017 12:59:00 +0000 (14:59 +0200)
src/plugins/lua/antivirus.lua

index e83308b4e7b304d151fb1560818fc0091a74d138..746d5e1cbd9c11cd6982392cbaccf10b0660ffad 100644 (file)
@@ -33,10 +33,6 @@ local function match_patterns(default_sym, found, patterns)
   return default_sym
 end
 
-local function trim(s)
-  return s:match "^%s*(.-)%s*$"
-end
-
 local function yield_result(task, rule, vname)
   local all_whitelisted = true
   if type(vname) == 'string' then
@@ -585,15 +581,14 @@ local function savapi_check(task, rule)
 
       -- Non-terminal response
       elseif string.find(result, '310') then
-        -- Recursive result
-        local virus_obj = rspamd_str_split(result, ' object ')
         local virus
-        if virus_obj and virus_obj[2] then
-          virus = rspamd_str_split(virus_obj[2], '<<<')
-          virus = trim(virus[#virus])
-          virus = rspamd_str_split(virus, ' ; ')[1]
-        else
-          virus = trim(rspamd_str_split(result, ' ; ')[1])
+        virus = result:match "310.*<<<%s(.*)%s+;.*;.*"
+        if not virus then
+          virus = result:match "310%s(.*)%s+;.*;.*"
+          if not virus then
+            rspamd_logger.errx(task, "%s: virus result unparseable: %s", rule['type'], result)
+            return
+          end
         end
         -- Store unique virus names
         vnames[virus] = 1