From 7ee0ad41f657b699d30425ac48b863d0e897588c Mon Sep 17 00:00:00 2001 From: Thomas Oettli Date: Wed, 12 Feb 2020 16:04:38 +0100 Subject: [PATCH] [Minor] Fix parsing DMARC records containing upper-case letters --- src/plugins/lua/dmarc.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua index 25bbc2513..62498270b 100644 --- a/src/plugins/lua/dmarc.lua +++ b/src/plugins/lua/dmarc.lua @@ -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() @@ -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 @@ -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 -- 2.39.5