-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add strict mode when parsing messages, typically enabled for incoming…
… special-use messages like tls/dmarc reports, subjectpass emails and pass a logger to the message parser, so problems with message parsing get the cid logged.
- Loading branch information
Showing
24 changed files
with
312 additions
and
153 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
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 |
---|---|---|
|
@@ -5,8 +5,12 @@ import ( | |
"reflect" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/mjl-/mox/mlog" | ||
) | ||
|
||
var xlog = mlog.New("dmarcrpt") | ||
|
||
const reportExample = `<?xml version="1.0" encoding="UTF-8" ?> | ||
<feedback> | ||
<report_metadata> | ||
|
@@ -130,15 +134,15 @@ func TestParseMessageReport(t *testing.T) { | |
if err != nil { | ||
t.Fatalf("open %q: %s", p, err) | ||
} | ||
_, err = ParseMessageReport(f) | ||
_, err = ParseMessageReport(xlog, f) | ||
if err != nil { | ||
t.Fatalf("ParseMessageReport: %q: %s", p, err) | ||
} | ||
f.Close() | ||
} | ||
|
||
// No report in a non-multipart message. | ||
_, err = ParseMessageReport(strings.NewReader("From: <[email protected]>\r\n\r\nNo report.\r\n")) | ||
_, err = ParseMessageReport(xlog, strings.NewReader("From: <[email protected]>\r\n\r\nNo report.\r\n")) | ||
if err != ErrNoReport { | ||
t.Fatalf("message without report, got err %#v, expected ErrNoreport", err) | ||
} | ||
|
@@ -164,7 +168,7 @@ MIME-Version: 1.0 | |
--===============5735553800636657282==-- | ||
`, "\n", "\r\n") | ||
_, err = ParseMessageReport(strings.NewReader(multipartNoreport)) | ||
_, err = ParseMessageReport(xlog, strings.NewReader(multipartNoreport)) | ||
if err != ErrNoReport { | ||
t.Fatalf("message without report, got err %#v, expected ErrNoreport", err) | ||
} | ||
|
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
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
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
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
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
Oops, something went wrong.