diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-03-11 12:27:26 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-03-11 12:27:26 +0000 |
commit | 698d4c87099a1b65a01b7f6179cacc9c867d726d (patch) | |
tree | c756f9a2bd6ab87ecdd33a636e28f7559e072508 /rules | |
parent | 3365f4ed9beb042fce3d397f1cd2ff72328e4c92 (diff) | |
download | rspamd-698d4c87099a1b65a01b7f6179cacc9c867d726d.tar.gz rspamd-698d4c87099a1b65a01b7f6179cacc9c867d726d.zip |
[Feature] Add symbols when tagged rcpt/sender are normalised
Diffstat (limited to 'rules')
-rw-r--r-- | rules/misc.lua | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/rules/misc.lua b/rules/misc.lua index 5abc2e821..1c69b7243 100644 --- a/rules/misc.lua +++ b/rules/misc.lua @@ -845,15 +845,15 @@ rspamd_config.OMOGRAPH_URL = { description = 'Url contains both latin and non-latin characters' } -rspamd_config:register_symbol{ +local aliases_id = rspamd_config:register_symbol{ type = 'prefilter', name = 'EMAIL_PLUS_ALIASES', callback = function(task) local function check_address(addr) if addr.user then - local cap = string.match(addr.user, '^([^%+][^%+]*)%+.*$') + local cap, pluses = string.match(addr.user, '^([^%+][^%+]*)(%+.*)$') if cap then - return cap + return cap, rspamd_str_split(pluses, '+') end end @@ -879,10 +879,12 @@ rspamd_config:register_symbol{ local function check_from(type) if task:has_from(type) then local addr = task:get_from(type)[1] - local na = check_address(addr) + local na,tags = check_address(addr) if na then set_addr(addr, na) task:set_from(type, addr) + task:insert_result('TAGGED_FROM', 1.0, fun.totable( + fun.filter(function(t) return t and #t > 0 end, tags))) end end end @@ -893,18 +895,22 @@ rspamd_config:register_symbol{ local function check_rcpt(type) if task:has_recipients(type) then local modified = false + local all_tags = {} local addrs = task:get_recipients(type) for _, addr in ipairs(addrs) do - local na = check_address(addr) + local na,tags = check_address(addr) if na then set_addr(addr, na) modified = true + fun.each(function(t) table.insert(all_tags, t) end, + fun.filter(function(t) return t and #t > 0 end, tags)) end end if modified then task:set_recipients(type, addrs) + task:insert_result('TAGGED_RCPT', 1.0, all_tags) end end end @@ -915,3 +921,18 @@ rspamd_config:register_symbol{ priority = 150, description = 'Removes plus aliases from the email', } + +rspamd_config:register_symbol{ + type = 'virtual', + parent = aliases_id, + name = 'TAGGED_RCPT', + description = 'SMTP recipients have plus tags', + score = 0, +} +rspamd_config:register_symbol{ + type = 'virtual', + parent = aliases_id, + name = 'TAGGED_FROM', + description = 'SMTP from has plus tags', + score = 0, +}
\ No newline at end of file |