diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-28 12:13:02 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-01-28 12:13:02 +0000 |
commit | 436ccb77ecdea5a70bb2d4627965551b6c3858b0 (patch) | |
tree | a46951bdfe5ea406420fb828388401359be3be2d /rules | |
parent | efd7390cf9d56b11437f920fc81d2107cf51d4d6 (diff) | |
download | rspamd-436ccb77ecdea5a70bb2d4627965551b6c3858b0.tar.gz rspamd-436ccb77ecdea5a70bb2d4627965551b6c3858b0.zip |
Fix rules to avoid nil indexing
Diffstat (limited to 'rules')
-rw-r--r-- | rules/misc.lua | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/rules/misc.lua b/rules/misc.lua index e84cc70d0..4bc8b3b90 100644 --- a/rules/misc.lua +++ b/rules/misc.lua @@ -139,7 +139,7 @@ rspamd_config.BROKEN_HEADERS = { if task:has_flag('broken_headers') then return true end - + return false end, score = 1.0, @@ -149,9 +149,13 @@ rspamd_config.BROKEN_HEADERS = { rspamd_config.HEADER_RCONFIRM_MISMATCH = { callback = function (task) - local header_from = task:get_from('mime')[1] + local header_from = nil local cread = task:get_header('X-Confirm-Reading-To') + if task:has_from('mime') then + header_from = task:get_from('mime')[1] + end + local header_cread = nil if cread then local headers_cread = util.parse_mail_address(cread) @@ -175,7 +179,11 @@ rspamd_config.HEADER_RCONFIRM_MISMATCH = { rspamd_config.HEADER_FORGED_MDN = { callback = function (task) local mdn = task:get_header('Disposition-Notification-To') - local header_rp = task:get_from('smtp')[1] + local header_rp = nil + + if task:has_from('smtp') then + header_rp = task:get_from('smtp')[1] + end -- Parse mail addr local header_mdn = nil @@ -210,20 +218,20 @@ rspamd_config.MULTIPLE_UNIQUE_HEADERS = { callback = function (task) local res = 0 local res_tbl = {} - + for i,hdr in ipairs(headers_unique) do local h = task:get_header_full(hdr) - + if h and #h > 1 then res = res + 1 table.insert(res_tbl, hdr) end end - + if res > 0 then return true,res,table.concat(res_tbl, ',') end - + return false end, |