diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-08-05 11:12:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-05 11:12:38 +0100 |
commit | 0290520fca17832999e8e75e455697be5d882b8e (patch) | |
tree | a3fa30f40d5b655acb560ae637b5c2da8aa7f4d4 | |
parent | 640c6f0f2df677c63bf602c03934394516c90121 (diff) | |
parent | 71b04b7dfcac774be357f9ac2ba44b6b9b31985e (diff) | |
download | rspamd-0290520fca17832999e8e75e455697be5d882b8e.tar.gz rspamd-0290520fca17832999e8e75e455697be5d882b8e.zip |
Merge pull request #810 from fatalbanana/dmarc
[Fix] Fix processing of last element of DMARC policies
-rw-r--r-- | src/plugins/lua/dmarc.lua | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua index f6dd8c75a..bafaa0eb7 100644 --- a/src/plugins/lua/dmarc.lua +++ b/src/plugins/lua/dmarc.lua @@ -37,6 +37,7 @@ local redis_params = nil local dmarc_redis_key_prefix = "dmarc_" local dmarc_domain = nil local elts_re = rspamd_regexp.create_cached("\\\\{0,1};\\s+") +local trim_re = rspamd_regexp.create_cached("(.+)\\\\{0,1};$") local dmarc_reporting = false local dmarc_actions = {} @@ -113,13 +114,17 @@ local function dmarc_callback(task) local elts = elts_re:split(r) if elts then + local trimmed = trim_re:search(elts[#elts], true, true) + if trimmed then + elts[#elts] = trimmed[1][2] + end for _,e in ipairs(elts) do dkim_pol = string.match(e, '^adkim=(.)$') if dkim_pol then if dkim_pol == 's' then strict_dkim = true elseif dkim_pol ~= 'r' then - failed_policy = 'adkim tag has invalid value' + failed_policy = 'adkim tag has invalid value: ' .. dkim_pol return end end @@ -128,7 +133,7 @@ local function dmarc_callback(task) if spf_pol == 's' then strict_spf = true elseif spf_pol ~= 'r' then - failed_policy = 'aspf tag has invalid value' + failed_policy = 'aspf tag has invalid value: ' .. spf_pol return end end @@ -140,7 +145,7 @@ local function dmarc_callback(task) strict_policy = true quarantine_policy = true elseif (policy ~= 'none') then - failed_policy = 'p tag has invalid value' + failed_policy = 'p tag has invalid value: ' .. policy return end end @@ -161,7 +166,7 @@ local function dmarc_callback(task) quarantine_policy = false end else - failed_policy = 'sp tag has invalid value' + failed_policy = 'sp tag has invalid value: ' .. subdomain_policy return end end |