diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-01-24 16:44:47 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-01-24 16:44:47 +0000 |
commit | 744d3ff5e587786db29e537d4683294780d6ab13 (patch) | |
tree | 7aeb8fdf9d00416d81e67368c14c19d9f18a9ed5 /conf | |
parent | d667c6b4ac9d23c1e2346d4286595f2d8503a640 (diff) | |
download | rspamd-744d3ff5e587786db29e537d4683294780d6ab13.tar.gz rspamd-744d3ff5e587786db29e537d4683294780d6ab13.zip |
Remove HFILTER_URL_ONELINE rule.
- Added functions:
`rspamd_textpart:get_length` - get a full length of text part
`rspamd_url:get_length` - get a full length of an URL object
- Removed `HFILTER_URL_ONELINE` as it is broken by nature
- Reworked hfilter to improve performance
Diffstat (limited to 'conf')
-rw-r--r-- | conf/lua/hfilter.lua | 42 | ||||
-rw-r--r-- | conf/metrics.conf | 1 |
2 files changed, 19 insertions, 24 deletions
diff --git a/conf/lua/hfilter.lua b/conf/lua/hfilter.lua index f0c4748a8..0ec54f1f4 100644 --- a/conf/lua/hfilter.lua +++ b/conf/lua/hfilter.lua @@ -250,28 +250,24 @@ local function hfilter(task) local parts = task:get_text_parts() if parts then --One text part-- - if table.maxn(parts) > 0 and parts[1]:get_content() then - local part_text = trim1(parts[1]:get_content()) - local total_part_len = string.len(part_text) - if total_part_len > 0 then - local urls = task:get_urls() - if urls then - local total_url_len = 0 - for _,url in ipairs(urls) do - total_url_len = total_url_len + string.len(url:get_text()) - end - if total_url_len > 0 then - if total_url_len + 7 > total_part_len then - task:insert_result('HFILTER_URL_ONLY', 1.00) - else - if not string.find(part_text, "\n") then - task:insert_result('HFILTER_URL_ONELINE', 1.00) - end - end - end - end - end - end + total_parts_len = 0 + for _,p in ipairs(parts) do + total_parts_len = total_parts_len + p:get_length() + end + if total_parts_len > 0 then + local urls = task:get_urls() + if urls then + local total_url_len = 0 + for _,url in ipairs(urls) do + total_url_len = total_url_len + url:get_length() + end + if total_url_len > 0 then + if total_url_len + 7 > total_part_len then + task:insert_result('HFILTER_URL_ONLY', 1.00) + end + end + end + end end return false @@ -284,4 +280,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_ONELINE"); +"HFILTER_URL_ONLY"); diff --git a/conf/metrics.conf b/conf/metrics.conf index 13b9796af..cba0ce18c 100644 --- a/conf/metrics.conf +++ b/conf/metrics.conf @@ -714,5 +714,4 @@ 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"; } } |