Skip to content

Commit

Permalink
Merge pull request #3263 from spacefreak86/dmarc
Browse files Browse the repository at this point in the history
[Minor] Fix parsing DMARC records containing upper-case letters
  • Loading branch information
vstakhov committed Feb 12, 2020
2 parents 3d224cf + 7ee0ad4 commit 2939a82
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/plugins/lua/dmarc.lua
Expand Up @@ -178,6 +178,23 @@ end

local dmarc_grammar = gen_dmarc_grammar()

local function dmarc_key_value_case(elts)
if type(elts) ~= "table" then
return elts
end
local result = {}
for k, v in pairs(elts) do
k = k:lower()
if k ~= "v" then
v = v:lower()
end

result[k] = v
end

return result
end

local function dmarc_report(task, spf_ok, dkim_ok, disposition,
sampled_out, hfromdom, spfdom, dres, spf_result)
local ip = task:get_from_ip()
Expand Down Expand Up @@ -228,6 +245,8 @@ local function dmarc_check_record(task, record, is_tld)
record, is_tld, elts)

if elts then
elts = dmarc_key_value_case(elts)

local dkim_pol = elts['adkim']
if dkim_pol then
if dkim_pol == 's' then
Expand Down Expand Up @@ -1129,7 +1148,7 @@ if opts['reporting'] == true then
failed_policy = true
elseif elts then
found_policy = true
policy = elts
policy = dmarc_key_value_case(elts)
end
end
if not found_policy then
Expand Down

0 comments on commit 2939a82

Please sign in to comment.