git » spf » commit e719437

redirect: Enforce maximum 1 redirect per record

author Alberto Bertogli
2019-10-14 02:05:12 UTC
committer Alberto Bertogli
2019-10-14 12:35:33 UTC
parent 525938d7a144d986d3a31ac8995dc78813140ded

redirect: Enforce maximum 1 redirect per record

Found by the standard test suite.

spf.go +5 -0

diff --git a/spf.go b/spf.go
index 5716cad..72677f7 100644
--- a/spf.go
+++ b/spf.go
@@ -190,6 +190,11 @@ func (r *resolution) Check(domain string) (Result, error) {
 			newfields = append(newfields, field)
 		}
 	}
+	if len(redirects) > 1 {
+		// At most a single redirect is allowed.
+		// https://tools.ietf.org/html/rfc7208#section-6
+		return PermError, errInvalidDomain
+	}
 	fields = append(newfields, redirects...)
 
 	for _, field := range fields {