]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Add check_for_mime('mime_attachement') function
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 23 Nov 2015 14:04:02 +0000 (14:04 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 23 Nov 2015 14:04:02 +0000 (14:04 +0000)
src/plugins/lua/spamassassin.lua

index 7f5376019bd9ff327b424d7bfb900330f1c5e6b9..fd1d628540e2586e01786997f965258deffe7f57 100644 (file)
@@ -291,6 +291,29 @@ local function gen_eval_rule(arg)
         return 0
       end
     },
+    {
+      'check_for_mime',
+      function(task, remain)
+        local arg = string.match(remain, "^%(%s*['\"]([^%s]+)['\"]%s*%)$")
+
+        if arg then
+          if arg == 'mime_attachment' then
+            local parts = task:get_parts()
+            if parts then
+              for i,p in ipairs(parts) do
+                if p:get_filename() then
+                  return 1
+                end
+              end
+            end
+          else
+            rspamd_logger.infox(task, 'unimplemented mime check %1', arg)
+          end
+        end
+
+        return 0
+      end
+    }
   }
 
   for k,f in ipairs(eval_funcs) do