From c955fadb6d09429ab80df419b1f691daf2f70636 Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Sat, 4 Nov 2023 13:22:30 +0100 Subject: [PATCH] fix parsing dmarc reports that come with content-type application/octet-stream by fixing a typo in the content-type... and by recognizing the application/x-zip that is detected as content-type. discovered when a dmarc report from aws ses wasn't processed. it seems aws ses was sending a dmarc report because it received a dmarc report. --- dmarcrpt/parse.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dmarcrpt/parse.go b/dmarcrpt/parse.go index 435f838..547b657 100644 --- a/dmarcrpt/parse.go +++ b/dmarcrpt/parse.go @@ -75,7 +75,7 @@ func parseReport(p message.Part) (*Feedback, error) { r := p.Reader() // If no (useful) content-type is set, try to detect it. - if ct == "" || ct == "application/octect-stream" { + if ct == "" || ct == "application/octet-stream" { data := make([]byte, 512) n, err := io.ReadFull(r, data) if err == io.EOF { @@ -92,7 +92,7 @@ func parseReport(p message.Part) (*Feedback, error) { case "application/zip": // Google sends messages with direct application/zip content-type. return parseZip(r) - case "application/gzip": + case "application/gzip", "application/x-gzip": gzr, err := gzip.NewReader(r) if err != nil { return nil, fmt.Errorf("decoding gzip xml report: %s", err)