From: Thomas Oettli Date: Thu, 12 Sep 2024 16:43:10 +0000 (+0200) Subject: [Fix] Rework DMARC to correctly handle spaces in DMARC records X-Git-Tag: 3.10.0~17^2~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=cf4ee94734b0d0cfd0f307210096d61ab062331e;p=rspamd.git [Fix] Rework DMARC to correctly handle spaces in DMARC records Issue: #4906 --- 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")