]> source.dussan.org Git - rspamd.git/commitdiff
Rework HFILTER_URL_ONELINE.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 25 Jan 2014 19:42:58 +0000 (19:42 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 25 Jan 2014 19:42:58 +0000 (19:42 +0000)
conf/lua/hfilter.lua
conf/metrics.conf

index d57c73ec335f76ef7d83245a7056326960993e77..3a7f812b105794bf2110227bf114bb4f742cc749 100644 (file)
@@ -250,9 +250,16 @@ local function hfilter(task)
     local parts = task:get_text_parts()
     if parts then
         --One text part--
-               total_parts_len = 0
+               local total_parts_len = 0
+               local text_parts_count = 0
+               local selected_text_part = nil
                for _,p in ipairs(parts) do
                        total_parts_len = total_parts_len + p:get_length()
+                       
+                       if not p:is_html() then
+                               text_parts_count = text_parts_count + 1
+                               selected_text_part = p
+                       end
                end
                if total_parts_len > 0 then
                        local urls = task:get_urls()
@@ -264,6 +271,14 @@ local function hfilter(task)
                                if total_url_len > 0 then
                                        if total_url_len + 7 > total_parts_len then
                                                task:insert_result('HFILTER_URL_ONLY', 1.00)
+                                       elseif text_parts_count == 1 and
+                                               selected_text_part:get_length() < 1024 then
+                                               -- We got a single text part with
+                                               -- the total length < 1024 symbols.
+                                               local part_text = trim1(selected_text_part:get_content())
+                                               if not string.find(part_text, "\n") then
+                                                       task:insert_result('HFILTER_URL_ONELINE', 1.00)
+                                               end
                                        end
                                end
                        end
@@ -280,4 +295,4 @@ rspamd_config:register_symbols(hfilter, 1.0,
 "HFILTER_FROMHOST_NORESOLVE_MX", "HFILTER_FROMHOST_NORES_A_OR_MX", "HFILTER_FROMHOST_NOT_FQDN",  
 "HFILTER_MID_NOT_FQDN",
 "HFILTER_HOSTNAME_NOPTR",
-"HFILTER_URL_ONLY");
+"HFILTER_URL_ONLY", "HFILTER_URL_ONELINE");
index cba0ce18cd498ad791d7104eb4aca498c88f53da..13b9796afe4f0f6ae3d51beb1b56b17b6e8fb4e0 100644 (file)
@@ -714,4 +714,5 @@ metric {
     symbol { weight = 0.50; name = "HFILTER_MID_NOT_FQDN"; description = "Message-id host not FQDN"; }
     symbol { weight = 4.00; name = "HFILTER_HOSTNAME_NOPTR"; description = "No PTR for IP"; }
     symbol { weight = 3.50; name = "HFILTER_URL_ONLY"; description = "URL only in body"; }
+    symbol { weight = 2.00; name = "HFILTER_URL_ONELINE"; description = "One line URL and text in body"; }
 }