From: Vsevolod Stakhov Date: Sat, 25 Jan 2014 19:42:58 +0000 (+0000) Subject: Rework HFILTER_URL_ONELINE. X-Git-Tag: 0.6.8~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46a763ca48a1f3475c97fbf0051093712ee5e4d9;p=thirdparty%2Frspamd.git Rework HFILTER_URL_ONELINE. --- diff --git a/conf/lua/hfilter.lua b/conf/lua/hfilter.lua index d57c73ec33..3a7f812b10 100644 --- a/conf/lua/hfilter.lua +++ b/conf/lua/hfilter.lua @@ -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"); diff --git a/conf/metrics.conf b/conf/metrics.conf index cba0ce18cd..13b9796afe 100644 --- a/conf/metrics.conf +++ b/conf/metrics.conf @@ -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"; } }