diff --git a/core/dnsserver/address.go b/core/dnsserver/address.go index 1a69c33b8..9146ef650 100644 --- a/core/dnsserver/address.go +++ b/core/dnsserver/address.go @@ -3,6 +3,7 @@ package dnsserver import ( "fmt" "net" + "net/url" "strings" "github.com/coredns/coredns/plugin" @@ -52,7 +53,13 @@ func normalizeZone(str string) (zoneAddr, error) { } } - return zoneAddr{Zone: dns.Fqdn(host), Port: port, Transport: trans, IPNet: ipnet}, nil + z := zoneAddr{Zone: dns.Fqdn(host), Port: port, Transport: trans, IPNet: ipnet} + _, err = url.ParseRequestURI(z.String()) + if err != nil { + return zoneAddr{}, err + } + + return z, nil } // SplitProtocolHostPort splits a full formed address like "dns://[::1]:53" into parts. diff --git a/core/dnsserver/address_test.go b/core/dnsserver/address_test.go index 6d4d0beab..86360d8f0 100644 --- a/core/dnsserver/address_test.go +++ b/core/dnsserver/address_test.go @@ -28,6 +28,7 @@ func TestNormalizeZone(t *testing.T) { {"https://.:8443", "https://.:8443", false}, {"https://..", "://:", true}, {"https://.:", "://:", true}, + {"dns://.:1053{.:53", "://:", true}, } { addr, err := normalizeZone(test.input) actual := addr.String()