fix parsing Authentication-Results header with a "reason=..." part

noticed in gopherwatch logging
This commit is contained in:
Mechiel Lukkien 2024-06-28 10:39:46 +02:00
parent 73373a19c1
commit 367e968199
No known key found for this signature in database
2 changed files with 18 additions and 0 deletions

View file

@ -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()
}

View file

@ -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)