Skip to content

Commit

Permalink
fix parsing Authentication-Results header with a "reason=..." part
Browse files Browse the repository at this point in the history
noticed in gopherwatch logging
  • Loading branch information
mjl- committed Jun 28, 2024
1 parent 73373a1 commit 367e968
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions message/authresults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
16 changes: 16 additions & 0 deletions message/authresults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 367e968

Please sign in to comment.