From cf4ee94734b0d0cfd0f307210096d61ab062331e Mon Sep 17 00:00:00 2001 From: Thomas Oettli Date: Thu, 12 Sep 2024 18:43:10 +0200 Subject: [PATCH] [Fix] Rework DMARC to correctly handle spaces in DMARC records Issue: #4906 --- lualib/plugins/dmarc.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lualib/plugins/dmarc.lua b/lualib/plugins/dmarc.lua index 38977ff58..b05a3a0ef 100644 --- a/lualib/plugins/dmarc.lua +++ b/lualib/plugins/dmarc.lua @@ -239,9 +239,9 @@ local function gen_dmarc_grammar() local lpeg = require "lpeg" lpeg.locale(lpeg) local space = lpeg.space ^ 0 - local name = lpeg.C(lpeg.alpha ^ 1) * space - local sep = space * (lpeg.S("\\;") * space) + (lpeg.P(lpeg.graph - lpeg.P(',')) * lpeg.space ^ 1) - local value = lpeg.C(lpeg.P(lpeg.P(lpeg.graph + lpeg.space) - sep) ^ 1) + local name = lpeg.C(lpeg.alpha ^ 1) + local sep = space * lpeg.S("\\;") * space + local value = lpeg.C(lpeg.P(lpeg.P((lpeg.space ^ 1) * lpeg.graph + lpeg.P(lpeg.graph)) - sep) ^ 1) local pair = lpeg.Cg(name * "=" * space * value) * sep ^ -1 local list = lpeg.Cf(lpeg.Ct("") * pair ^ 0, rawset) local version = lpeg.P("v") * space * lpeg.P("=") * space * lpeg.P("DMARC1") -- 2.39.5