Spec qualified names (label keys) more tightly
It can be a (DNS_SUBDOMAIN/)?label, but we were validating it incorrectly before.
This commit is contained in:
@@ -168,24 +168,30 @@ func TestIsQualifiedName(t *testing.T) {
|
||||
"1-num.2-num/3-num",
|
||||
"1234/5678",
|
||||
"1.2.3.4/5678",
|
||||
"UppercaseIsOK123",
|
||||
"Uppercase_Is_OK_123",
|
||||
"example.com/Uppercase_Is_OK_123",
|
||||
strings.Repeat("a", 63),
|
||||
strings.Repeat("a", 253) + "/" + strings.Repeat("b", 63),
|
||||
}
|
||||
for i := range successCases {
|
||||
if !IsQualifiedName(successCases[i]) {
|
||||
t.Errorf("case[%d] expected success", i)
|
||||
t.Errorf("case[%d]: %q: expected success", i, successCases[i])
|
||||
}
|
||||
}
|
||||
|
||||
errorCases := []string{
|
||||
"nospecialchars%^=@",
|
||||
"cantendwithadash-",
|
||||
"-cantstartwithadash-",
|
||||
"only/one/slash",
|
||||
strings.Repeat("a", 254),
|
||||
"-cantstartwithadash",
|
||||
"Example.com/abc",
|
||||
"example_com/abc",
|
||||
strings.Repeat("a", 64),
|
||||
strings.Repeat("a", 254) + "/abc",
|
||||
}
|
||||
for i := range errorCases {
|
||||
if IsQualifiedName(errorCases[i]) {
|
||||
t.Errorf("case[%d] expected failure", i)
|
||||
t.Errorf("case[%d]: %q: expected failure", i, errorCases[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user