Simplify DNS validation checks

Move DNS length checks to util/validation.go.  Make the max subdomain be 253,
which is what the RFC actually says.
This commit is contained in:
Tim Hockin
2014-07-08 13:44:30 -07:00
parent 40c71e8292
commit 8d6e832b8e
4 changed files with 35 additions and 26 deletions

View File

@@ -17,6 +17,7 @@ limitations under the License.
package util
import (
"strings"
"testing"
)
@@ -37,6 +38,7 @@ func TestIsDNSLabel(t *testing.T) {
"_", "a_", "_a", "a_b", "1_", "_1", "1_2",
".", "a.", ".a", "a.b", "1.", ".1", "1.2",
" ", "a ", " a", "a b", "1 ", " 1", "1 2",
strings.Repeat("a", 64),
}
for _, val := range badValues {
if IsDNSLabel(val) {
@@ -73,6 +75,7 @@ func TestIsDNSSubdomain(t *testing.T) {
"A.B.C.D.E", "AA.BB.CC.DD.EE", "a.B.c.d.e", "aa.bB.cc.dd.ee",
"a@b", "a,b", "a_b", "a;b",
"a:b", "a%b", "a?b", "a$b",
strings.Repeat("a", 254),
}
for _, val := range badValues {
if IsDNSSubdomain(val) {