]> source.dussan.org Git - rspamd.git/commitdiff
Fix rules to avoid nil indexing
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 28 Jan 2016 12:13:02 +0000 (12:13 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 28 Jan 2016 12:13:02 +0000 (12:13 +0000)
rules/misc.lua

index e84cc70d0d2bb28c012ffec2bbb2b7423906fa0d..4bc8b3b90fb952d36f024a53d54f2d152a9bae08 100644 (file)
@@ -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,