From: Christian Roessner Date: Fri, 5 May 2017 10:00:25 +0000 (+0200) Subject: [Minor] Fix result parsing for SAVAPI X-Git-Tag: 1.5.8~18 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5f38d503fd9bf42cae11ef13d299263cdaeb3b99;p=rspamd.git [Minor] Fix result parsing for SAVAPI --- diff --git a/src/plugins/lua/antivirus.lua b/src/plugins/lua/antivirus.lua index e83308b4e..746d5e1cb 100644 --- a/src/plugins/lua/antivirus.lua +++ b/src/plugins/lua/antivirus.lua @@ -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