From: Andrew Lewis Date: Fri, 13 Feb 2015 09:30:41 +0000 (+0200) Subject: hfilter.lua: Add exclusion for authenticated users (except link checks) X-Git-Tag: 0.8.2~48^2~8 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=482a84e1c501df4d402676af8b86845fd3009abf;p=rspamd.git hfilter.lua: Add exclusion for authenticated users (except link checks) --- diff --git a/conf/lua/hfilter.lua b/conf/lua/hfilter.lua index cd6d7d3dc..2cecfeea4 100644 --- a/conf/lua/hfilter.lua +++ b/conf/lua/hfilter.lua @@ -167,6 +167,49 @@ end -- local function hfilter(task) + -- Links checks + if config['url_enabled'] then + local parts = task:get_text_parts() + if parts then + --One text part-- + 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() + 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_parts_len then + task:insert_result('HFILTER_URL_ONLY', 1.00) + elseif text_parts_count == 1 and selected_text_part and selected_text_part:get_length() < 1024 then + -- We got a single text part with the total length < 1024 symbols. + local part_text = selected_text_part:get_content() + if part_text and not string.find(trim1(part_text), "\n") then + task:insert_result('HFILTER_URL_ONELINE', 1.00) + end + end + end + end + end + end + end + + if task:get_user() ~= nil then + return + end + --IP-- local ip = false local rip = task:get_from_ip() @@ -261,45 +304,6 @@ local function hfilter(task) end end - -- Links checks - if config['url_enabled'] then - local parts = task:get_text_parts() - if parts then - --One text part-- - 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() - 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_parts_len then - task:insert_result('HFILTER_URL_ONLY', 1.00) - elseif text_parts_count == 1 and selected_text_part and selected_text_part:get_length() < 1024 then - -- We got a single text part with the total length < 1024 symbols. - local part_text = selected_text_part:get_content() - if part_text and not string.find(trim1(part_text), "\n") then - task:insert_result('HFILTER_URL_ONELINE', 1.00) - end - end - end - end - end - end - end - return false end