Forbid backslashes in group names.
We used to only forbid them under Windows.
This commit is contained in:
1 parent
410764618e
commit
7f93a49680
2 files changed
+7
-2
No files matched your search
+6
-2
@@ -420,10 +420,14 @@ func Add(name string, desc *Description) (*Group, error) {
|
||||
}
|
||||
|
||||
func validGroupName(name string) bool {
|
||||
if filepath.Separator != '/' &&
|
||||
strings.ContainsRune(name, filepath.Separator) {
|
||||
if strings.ContainsRune(name, '\\') {
|
||||
return false
|
||||
}
|
||||
if s := filepath.Separator; s != '/' && s != '\\' {
|
||||
if strings.ContainsRune(name, s) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
s := path.Clean("/" + name)
|
||||
if s == "/" {
|
||||
|
||||
@@ -338,6 +338,7 @@ func TestValidGroupName(t *testing.T) {
|
||||
{"foo/..", false},
|
||||
{"foo/./bar", false},
|
||||
{"foo/../bar", false},
|
||||
{"foo\\bar", false},
|
||||
{"foo", true},
|
||||
{"foo/bar", true},
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user