Validate zone during normalization (#3165)
This commit is contained in:
parent
27f44f60ee
commit
f888c5f7f6
2 changed files with 9 additions and 1 deletions
|
@ -3,6 +3,7 @@ package dnsserver
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/coredns/coredns/plugin"
|
"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.
|
// SplitProtocolHostPort splits a full formed address like "dns://[::1]:53" into parts.
|
||||||
|
|
|
@ -28,6 +28,7 @@ func TestNormalizeZone(t *testing.T) {
|
||||||
{"https://.:8443", "https://.:8443", false},
|
{"https://.:8443", "https://.:8443", false},
|
||||||
{"https://..", "://:", true},
|
{"https://..", "://:", true},
|
||||||
{"https://.:", "://:", true},
|
{"https://.:", "://:", true},
|
||||||
|
{"dns://.:1053{.:53", "://:", true},
|
||||||
} {
|
} {
|
||||||
addr, err := normalizeZone(test.input)
|
addr, err := normalizeZone(test.input)
|
||||||
actual := addr.String()
|
actual := addr.String()
|
||||||
|
|
Loading…
Add table
Reference in a new issue