]> source.dussan.org Git - rspamd.git/commitdiff
Add improved version of R_EMPTY_IMAGE.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 23 Jul 2015 16:20:37 +0000 (17:20 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 23 Jul 2015 16:20:37 +0000 (17:20 +0100)
conf/lua/html.lua
conf/lua/rspamd.lua

index bd7abd987a8d50dcce2a5f48f537cf09ddbc9fa4..161bbe3b581109f17bb31a0280aaa1b6311d0416 100644 (file)
@@ -15,6 +15,7 @@
 
 local reconf = config['regexp']
 local rspamd_regexp = require "rspamd_regexp"
+local rspamd_logger = require "rspamd_logger"
 
 -- Messages that have only HTML part
 reconf['MIME_HTML_ONLY'] = 'has_only_html_part()'
@@ -50,4 +51,26 @@ rspamd_config.HTML_SHORT_LINK_IMG_2 = function(task)
 end
 rspamd_config.HTML_SHORT_LINK_IMG_3 = function(task)
   return check_html_image(task, 1536, 2048)
+end
+rspamd_config.R_EMPTY_IMAGE = function(task)
+  local tp = task:get_text_parts()
+  
+  for _,p in ipairs(tp) do
+    if p:is_html() then
+      local hc = p:get_html()
+      local lines = p:get_lines_count()
+      
+      if lines < 5 then
+        local images = hc:get_images()
+        
+        if images then
+          for _,i in ipairs(images) do
+            if i['height'] + i['width'] >= 400 then
+              return true
+            end
+          end
+        end
+      end
+    end
+  end
 end
\ No newline at end of file
index bb1709c6922e33775f5608079c882324ba07627f..ce2edd2b318e773ccc590613206426aa3e0d9ec0 100644 (file)
@@ -62,22 +62,6 @@ rspamd_config.R_PARTS_DIFFER = function(task)
   return false
 end
 
-rspamd_config.R_EMPTY_IMAGE = function (task)
-       parts = task:get_text_parts()
-       if parts then
-               for _,part in ipairs(parts) do
-                       if part:is_empty() then
-                               images = task:get_images()
-                               if images then
-                                       return true
-                               end
-                               return false
-                       end
-               end
-       end
-       return false
-end
-
 -- Date issues
 rspamd_config.MISSING_DATE = function(task)
        if rspamd_config:get_api_version() >= 5 then