diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-01-25 19:42:58 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-01-25 19:42:58 +0000 |
commit | 48fdd5aea934eb1a7f72900d7aa7b923af2fb9ee (patch) | |
tree | 5302715715ffeea491a10bd26640e2661aa5b2f2 /conf/lua | |
parent | cdb03c5fa8b381e8fc22d609598dd56901185adc (diff) | |
download | rspamd-48fdd5aea934eb1a7f72900d7aa7b923af2fb9ee.tar.gz rspamd-48fdd5aea934eb1a7f72900d7aa7b923af2fb9ee.zip |
Rework HFILTER_URL_ONELINE.
Diffstat (limited to 'conf/lua')
-rw-r--r-- | conf/lua/hfilter.lua | 19 |
1 files changed, 17 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"); |