summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-02-05 15:10:56 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-02-05 15:10:56 +0000
commit9f1b796c983bc11d5a6865e0cb5b9a274d51d577 (patch)
tree9aec66e698bed0678a73e2ba53b0acc843b1e836
parentb4bc6269d9bf967d0703ddf1508446686f677c56 (diff)
parentdd6a81c69709df2bdff9f95df5630baa5ed1b30e (diff)
downloadrspamd-9f1b796c983bc11d5a6865e0cb5b9a274d51d577.tar.gz
rspamd-9f1b796c983bc11d5a6865e0cb5b9a274d51d577.zip
Merge pull request #41 from AlexeySa/patch-1
Fix Hfilter for null text part
-rw-r--r--conf/lua/hfilter.lua64
1 files changed, 31 insertions, 33 deletions
diff --git a/conf/lua/hfilter.lua b/conf/lua/hfilter.lua
index 0c1d887e8..60a5cd722 100644
--- a/conf/lua/hfilter.lua
+++ b/conf/lua/hfilter.lua
@@ -251,39 +251,37 @@ local function hfilter(task)
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: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
- end
+ 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
return false