From: Vsevolod Stakhov Date: Sun, 5 Jun 2016 18:36:06 +0000 (+0200) Subject: [Fix] Fix processing of messages without received headers X-Git-Tag: 1.3.0~404 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64022c191d7234f52dccc6d4009bf3b7d0491074;p=thirdparty%2Frspamd.git [Fix] Fix processing of messages without received headers --- diff --git a/rules/forwarding.lua b/rules/forwarding.lua index 6ee0b9a97f..c5c8912afc 100644 --- a/rules/forwarding.lua +++ b/rules/forwarding.lua @@ -81,24 +81,27 @@ rspamd_config.FORWARDED = { local matches = 0 -- Retrieve and loop through all Received headers local rcvds = task:get_header_full('Received') - for _, rcvd in ipairs(rcvds) do + + if rcvds then + for _, rcvd in ipairs(rcvds) do local _,_,addr = rcvd['decoded']:lower():find("%sfor%s<(.-)>") if addr then - matches = matches + 1 - -- Check that it doesn't match the envrcpt - -- TODO: remove any plus addressing? - if addr ~= envrcpts[1].addr:lower() then - -- Check for mailing-lists as they will have the same signature - if matches < 2 and lu and to and to[1].addr:lower() == addr then - return false - else - return true, addr - end + matches = matches + 1 + -- Check that it doesn't match the envrcpt + -- TODO: remove any plus addressing? + if addr ~= envrcpts[1].addr:lower() then + -- Check for mailing-lists as they will have the same signature + if matches < 2 and lu and to and to[1].addr:lower() == addr then + return false + else + return true, addr end - -- Prevent any other iterations as we only want - -- process the first matching Received header - return false + end + -- Prevent any other iterations as we only want + -- process the first matching Received header + return false end + end end return false end,