forked from emersion/go-msgauth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite of the Authenctication-Results header parser for full RFC 7601 compliance. Ignore any header comments in parenthesis. Allow escape sequences and semi-colons in comments and quoted strings as values. Fixes: emersion#32
- Loading branch information
Showing
2 changed files
with
239 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,22 @@ var parseTests = []msgauthTest{ | |
&SPFResult{Value: ResultPass, From: "example.net"}, | ||
}, | ||
}, | ||
{ | ||
value: "example.com; \r\n" + | ||
" \t spf=pass reason=\"looks good\" smtp.mailfrom=example.net", | ||
identifier: "example.com", | ||
results: []Result{ | ||
&SPFResult{Value: ResultPass, Reason: "looks good", From: "example.net"}, | ||
}, | ||
}, | ||
{ | ||
value: "example.com; \r\n" + | ||
" \t spf=pass reason=\"looks; good\" smtp.mailfrom=example.net", | ||
identifier: "example.com", | ||
results: []Result{ | ||
&SPFResult{Value: ResultPass, Reason: "looks; good", From: "example.net"}, | ||
}, | ||
}, | ||
{ | ||
value: "example.com;" + | ||
" auth=pass (cram-md5) [email protected];", | ||
|
@@ -32,6 +48,50 @@ var parseTests = []msgauthTest{ | |
&AuthResult{Value: ResultPass, Auth: "[email protected]"}, | ||
}, | ||
}, | ||
{ | ||
value: "example.com;" + | ||
" auth=pass (cram-md5) [email protected];" + | ||
" spf=pass smtp.mailfrom=example.net", | ||
identifier: "example.com", | ||
results: []Result{ | ||
&AuthResult{Value: ResultPass, Auth: "[email protected]"}, | ||
&SPFResult{Value: ResultPass, From: "example.net"}, | ||
}, | ||
}, | ||
{ | ||
value: "example.com;" + | ||
" auth=pass (cram-md5 (comment inside comment)) [email protected];", | ||
identifier: "example.com", | ||
results: []Result{ | ||
&AuthResult{Value: ResultPass, Auth: "[email protected]"}, | ||
}, | ||
}, | ||
{ | ||
value: "example.com;" + | ||
" auth=pass (cram-md5; comment with semicolon) [email protected];", | ||
identifier: "example.com", | ||
results: []Result{ | ||
&AuthResult{Value: ResultPass, Auth: "[email protected]"}, | ||
}, | ||
}, | ||
{ | ||
value: "example.com;" + | ||
" auth=pass (cram-md5 \\( comment with semicolon) [email protected];", | ||
identifier: "example.com", | ||
results: []Result{ | ||
&AuthResult{Value: ResultPass, Auth: "[email protected]"}, | ||
}, | ||
}, | ||
{ | ||
value: "foo.example.net (foobar) 1 (baz);" + | ||
" dkim (Because I like it) / 1 (One yay) = (wait for it) fail" + | ||
" policy (A dot can go here) . (like that) expired" + | ||
" (this surprised me) = (as I wasn't expecting it) 1362471462", | ||
identifier: "foo.example.net", | ||
results: []Result{ | ||
&DKIMResult{Value: ResultFail, Reason: "", Domain: "", Identifier: ""}, | ||
}, | ||
}, | ||
} | ||
|
||
func TestParse(t *testing.T) { | ||
|