]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Feature] Support archives when matching patterns in multimap
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 4 Jul 2016 16:05:59 +0000 (17:05 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 4 Jul 2016 16:05:59 +0000 (17:05 +0100)
src/plugins/lua/multimap.lua

index 9f0d9284933bf0d918b24536c17b9800077a1ed9..786a9a49245fbbe4c653ec18a75bd31be54c1903 100644 (file)
@@ -344,16 +344,28 @@ local function multimap_callback(task, pre_filter)
     end
   end
   -- Filename rules
+  local function check_file(fn)
+    _.each(function(r)
+          match_filename(r, fn)
+        end,
+        _.filter(function(r)
+          return pre_filter == r['prefilter'] and r['type'] == 'filename'
+        end, rules))
+  end
+
   local parts = task:get_parts()
   for i,p in ipairs(parts) do
-    local fn = p:get_filename()
-    if fn then
-      _.each(function(r)
-        match_filename(r, fn)
-      end,
-      _.filter(function(r)
-        return pre_filter == r['prefilter'] and r['type'] == 'filename'
-      end, rules))
+    if p:is_archive() then
+      local fnames = p:get_archive():get_files()
+
+      for ii,fn in ipairs(fnames) do
+        check_file(fn)
+      end
+    else
+      local fn = p:get_filename()
+      if fn then
+        check_file(fn)
+      end
     end
   end
   -- RBL rules