diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-08-07 11:41:28 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-08-07 11:41:28 +0100 |
commit | 662145d0554de5e769b92dab2d41173a98adcee5 (patch) | |
tree | ec28311a0bce6181f248ba7b50304293ad764e44 /rules/forwarding.lua | |
parent | bbd88232db43d18f5e0de5a6502848d4074621c5 (diff) | |
download | rspamd-662145d0554de5e769b92dab2d41173a98adcee5.tar.gz rspamd-662145d0554de5e769b92dab2d41173a98adcee5.zip |
[Minor] Reformat all Lua code, no functional changes
Diffstat (limited to 'rules/forwarding.lua')
-rw-r--r-- | rules/forwarding.lua | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/rules/forwarding.lua b/rules/forwarding.lua index 7d79a0c31..a008c587d 100644 --- a/rules/forwarding.lua +++ b/rules/forwarding.lua @@ -19,22 +19,24 @@ limitations under the License. local rspamd_util = require "rspamd_util" rspamd_config.FWD_GOOGLE = { - callback = function (task) + callback = function(task) if not (task:has_from(1) and task:has_recipients(1)) then return false end - local envfrom = task:get_from{'smtp', 'orig'} + local envfrom = task:get_from { 'smtp', 'orig' } local envrcpts = task:get_recipients(1) -- Forwarding will only be to a single recipient - if #envrcpts > 1 then return false end + if #envrcpts > 1 then + return false + end -- Get recipient and compute VERP address local rcpt = envrcpts[1].addr:lower() - local verp = rcpt:gsub('@','=') + local verp = rcpt:gsub('@', '=') -- Get the user portion of the envfrom local ef_user = envfrom[1].user:lower() -- Check for a match if ef_user:find('+caf_=' .. verp, 1, true) then - local _,_,user = ef_user:find('^(.+)+caf_=') + local _, _, user = ef_user:find('^(.+)+caf_=') if user then user = user .. '@' .. envfrom[1].domain return true, user @@ -48,7 +50,7 @@ rspamd_config.FWD_GOOGLE = { } rspamd_config.FWD_YANDEX = { - callback = function (task) + callback = function(task) if not (task:has_from(1) and task:has_recipients(1)) then return false end @@ -64,7 +66,7 @@ rspamd_config.FWD_YANDEX = { } rspamd_config.FWD_MAILRU = { - callback = function (task) + callback = function(task) if not (task:has_from(1) and task:has_recipients(1)) then return false end @@ -80,14 +82,16 @@ rspamd_config.FWD_MAILRU = { } rspamd_config.FWD_SRS = { - callback = function (task) + callback = function(task) if not (task:has_from(1) and task:has_recipients(1)) then return false end local envfrom = task:get_from(1) local envrcpts = task:get_recipients(1) -- Forwarding is only to a single recipient - if #envrcpts > 1 then return false end + if #envrcpts > 1 then + return false + end -- Get recipient and compute rewritten SRS address local srs = '=' .. envrcpts[1].domain:lower() .. '=' .. envrcpts[1].user:lower() @@ -104,10 +108,10 @@ rspamd_config.FWD_SRS = { } rspamd_config.FORWARDED = { - callback = function (task) + callback = function(task) local function normalize_addr(addr) addr = string.match(addr, '^<?([^>]*)>?$') or addr - local cap, _,domain = string.match(addr, '^([^%+][^%+]*)(%+[^@]*)@(.*)$') + local cap, _, domain = string.match(addr, '^([^%+][^%+]*)(%+[^@]*)@(.*)$') if cap then addr = string.format('%s@%s', cap, domain) end @@ -115,10 +119,14 @@ rspamd_config.FORWARDED = { return addr end - if not task:has_recipients(1) or not task:has_recipients(2) then return false end + if not task:has_recipients(1) or not task:has_recipients(2) then + return false + end local envrcpts = task:get_recipients(1) -- Forwarding will only be for single recipient messages - if #envrcpts > 1 then return false end + if #envrcpts > 1 then + return false + end -- Get any other headers we might need local has_list_unsub = task:has_header('List-Unsubscribe') local to = task:get_recipients(2) |