diff --git a/pkg/normalize/validate.go b/pkg/normalize/validate.go index f14607f3c..06956de1b 100644 --- a/pkg/normalize/validate.go +++ b/pkg/normalize/validate.go @@ -10,6 +10,7 @@ import ( "github.com/StackExchange/dnscontrol/providers" "github.com/miekg/dns" "github.com/miekg/dns/dnsutil" + "github.com/pkg/errors" ) // Returns false if target does not validate. @@ -36,6 +37,9 @@ func checkTarget(target string) error { if len(target) < 1 { return fmt.Errorf("empty target") } + if strings.ContainsAny(target, `'" +,|!£$%&/()=?^*ç°§;:_<>[]()@`) { + return errors.Errorf("target (%v) includes invalid char", target) + } // If it containts a ".", it must end in a ".". if strings.ContainsRune(target, '.') && target[len(target)-1] != '.' { return fmt.Errorf("target (%v) must end with a (.) [Required if target is not single label]", target) diff --git a/pkg/normalize/validate_test.go b/pkg/normalize/validate_test.go index 5da41941c..65a77c664 100644 --- a/pkg/normalize/validate_test.go +++ b/pkg/normalize/validate_test.go @@ -64,6 +64,10 @@ func Test_assert_valid_target(t *testing.T) { {"foo.bar.", false}, {"foo.", false}, {"foo.bar", true}, + {"foo&bar", true}, + {"foo bar", true}, + {"elb21.freshdesk.com/", true}, + {"elb21.freshdesk.com/.", true}, } for _, test := range tests {