Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(label): tolerate backslash in the label name (#1595) #2083

Merged
merged 2 commits into from Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions server/util.go
Expand Up @@ -296,10 +296,10 @@ func InitHTTPClient(svr *Server) error {
return nil
}

const matchRule = "^[A-Za-z0-9]([-A-Za-z0-9_.]*[A-Za-z0-9])?$"
const matchRule = "^[A-Za-z0-9]([-A-Za-z0-9_./]*[A-Za-z0-9])?$"

// ValidateLabelString checks the legality of the label string.
// The valid label consist of alphanumeric characters, '-', '_' or '.',
// The valid label consists of alphanumeric characters, '-', '_', '.' or '/',
// and must start and end with an alphanumeric character.
func ValidateLabelString(s string) error {
isValid, _ := regexp.MatchString(matchRule, s)
Expand Down
3 changes: 3 additions & 0 deletions server/util_test.go
Expand Up @@ -68,6 +68,9 @@ func (s *testUtilSuite) TestVerifyLabels(c *C) {
{"www.pingcap.com", false},
{"h_127.0.0.1", false},
{"a", false},
{"a/b", false},
{"ab/", true},
{"/ab", true},
}
for _, t := range tests {
c.Assert(ValidateLabelString(t.label) != nil, Equals, t.hasErr)
Expand Down