From 367e968199bbd260be958eb0f59ed8da0f63d83c Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Fri, 28 Jun 2024 10:39:46 +0200 Subject: [PATCH] fix parsing Authentication-Results header with a "reason=..." part noticed in gopherwatch logging --- message/authresults.go | 2 ++ message/authresults_test.go | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/message/authresults.go b/message/authresults.go index e3443e2..462aa2d 100644 --- a/message/authresults.go +++ b/message/authresults.go @@ -424,6 +424,8 @@ func (p *parser) xresinfo(methodKeyword string) (am AuthMethod) { am.Method, am.Version, am.Result = p.xmethodspec(methodKeyword) p.cfws() if p.take("reason") { + p.cfws() + p.xtake("=") p.cfws() am.Reason = p.xvalue() } diff --git a/message/authresults_test.go b/message/authresults_test.go index ecab540..69251ce 100644 --- a/message/authresults_test.go +++ b/message/authresults_test.go @@ -311,6 +311,22 @@ func TestAuthResultsParse(t *testing.T) { }, }) + const dkimReason = `host.example; + dkim=none reason="no dkim signatures" +` + ar, err = ParseAuthResults(dkimReason) + tcheck(t, err, "parsing auth results header") + tcompare(t, ar, AuthResults{ + Hostname: "host.example", + Methods: []AuthMethod{ + { + Method: "dkim", + Result: "none", + Reason: "no dkim signatures", + }, + }, + }) + // Outlook adds an invalid line, missing required hostname at the start. And their // dmarc "action=none" is invalid. Nothing to be done. const outlook = `x; spf=pass (sender IP is 84.22.96.237)