]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix URI_COUNT_ODD rule
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 16 Mar 2017 18:23:31 +0000 (18:23 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 16 Mar 2017 18:23:31 +0000 (18:23 +0000)
rules/misc.lua

index 2bba06e914447e3043a65a1b07b424f68522e305..846da24d80483ad43f80a6a972ed624bd9fefb09 100644 (file)
@@ -232,9 +232,13 @@ rspamd_config.URI_COUNT_ODD = {
   callback = function (task)
     local ct = task:get_header('Content-Type')
     if (ct and ct:lower():find('^multipart/alternative')) then
-      local urls = task:get_urls()
-      if (urls and (#urls % 2 == 1)) then
-        return true, 1.0, tostring(#urls % 2)
+      local urls = task:get_urls() or {}
+      local nurls = fun.filter(function(url)
+        return not url:is_html_displayed()
+      end, urls):foldl(function(acc, val) return acc + 1 end, 0)
+
+      if nurls % 2 == 1 then
+        return true, 1.0, tostring(nurls)
       end
     end
   end,