commit 7ee0ad4: [Minor] Fix parsing DMARC records containing upper-case letters

Thomas Oettli spacefreak at noop.ch
Wed Feb 12 19:56:06 UTC 2020


Author: Thomas Oettli
Date: 2020-02-12 16:04:38 +0100
URL: https://github.com/rspamd/rspamd/commit/7ee0ad41f657b699d30425ac48b863d0e897588c (refs/pull/3263/head)

[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


More information about the Commits mailing list