]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix result parsing for SAVAPI 1615/head
authorChristian Roessner <c@roessner-network-solutions.com>
Fri, 5 May 2017 10:00:25 +0000 (12:00 +0200)
committerChristian Roessner <c@roessner-network-solutions.com>
Fri, 5 May 2017 15:50:15 +0000 (17:50 +0200)
src/plugins/lua/antivirus.lua

index 63d2685ec72fc37b41a7314ea84b8a1a4ff18326..0b9bf0b22115f738a44ee8a6cff4a077d8de5c0c 100644 (file)
@@ -73,10 +73,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
@@ -625,15 +621,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