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.
This commit is contained in:
Mechiel Lukkien 2023-11-04 13:22:30 +01:00
parent 3a7ed9738a
commit c955fadb6d
No known key found for this signature in database

View file

@ -75,7 +75,7 @@ func parseReport(p message.Part) (*Feedback, error) {
r := p.Reader() r := p.Reader()
// If no (useful) content-type is set, try to detect it. // 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) data := make([]byte, 512)
n, err := io.ReadFull(r, data) n, err := io.ReadFull(r, data)
if err == io.EOF { if err == io.EOF {
@ -92,7 +92,7 @@ func parseReport(p message.Part) (*Feedback, error) {
case "application/zip": case "application/zip":
// Google sends messages with direct application/zip content-type. // Google sends messages with direct application/zip content-type.
return parseZip(r) return parseZip(r)
case "application/gzip": case "application/gzip", "application/x-gzip":
gzr, err := gzip.NewReader(r) gzr, err := gzip.NewReader(r)
if err != nil { if err != nil {
return nil, fmt.Errorf("decoding gzip xml report: %s", err) return nil, fmt.Errorf("decoding gzip xml report: %s", err)