aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-01-25 19:42:58 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-01-25 19:42:58 +0000
commit48fdd5aea934eb1a7f72900d7aa7b923af2fb9ee (patch)
tree5302715715ffeea491a10bd26640e2661aa5b2f2
parentcdb03c5fa8b381e8fc22d609598dd56901185adc (diff)
downloadrspamd-48fdd5aea934eb1a7f72900d7aa7b923af2fb9ee.tar.gz
rspamd-48fdd5aea934eb1a7f72900d7aa7b923af2fb9ee.zip
Rework HFILTER_URL_ONELINE.
-rw-r--r--conf/lua/hfilter.lua19
-rw-r--r--conf/metrics.conf1
2 files changed, 18 insertions, 2 deletions
diff --git a/conf/lua/hfilter.lua b/conf/lua/hfilter.lua
index d57c73ec3..3a7f812b1 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 cba0ce18c..13b9796af 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"; }
}