From 31cf9789b42889e03ce6291bca7ecd01ce2c2a5f Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Mon, 6 Jul 2020 15:40:52 +0200 Subject: [PATCH] svcs.SPF: Remove duplicate fields --- services/email.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/services/email.go b/services/email.go index 4ab7c49..eae07ed 100644 --- a/services/email.go +++ b/services/email.go @@ -290,7 +290,18 @@ func email_analyze(a *Analyzer) (err error) { } if txt, ok := record.(*dns.TXT); ok { - service.SPF.Content += strings.TrimSpace(strings.Join(txt.Txt, "")) + " " + fields := strings.Fields(service.SPF.Content + " " + strings.TrimPrefix(strings.TrimSpace(strings.Join(txt.Txt, "")), "v=spf1")) + + for i := 0; i < len(fields); i += 1 { + for j := i + 1; j < len(fields); j += 1 { + if fields[i] == fields[j] { + fields = append(fields[:j], fields[j+1:]...) + j -= 1 + } + } + } + + service.SPF.Content = strings.Join(fields, " ") } err = a.useRR(record, domain, service)