Forbid backslashes in group names.

We used to only forbid them under Windows.
This commit is contained in:
Juliusz Chroboczek committed 2025-01-17 12:17:31 +01:00
1 parent 410764618e
commit 7f93a49680
2 files changed
+7 -2

No files matched your search

+6 -2
View File
@@ -420,10 +420,14 @@ func Add(name string, desc *Description) (*Group, error) {
} }
func validGroupName(name string) bool { func validGroupName(name string) bool {
if filepath.Separator != '/' && if strings.ContainsRune(name, '\\') {
strings.ContainsRune(name, filepath.Separator) {
return false return false
} }
if s := filepath.Separator; s != '/' && s != '\\' {
if strings.ContainsRune(name, s) {
return false
}
}
s := path.Clean("/" + name) s := path.Clean("/" + name)
if s == "/" { if s == "/" {
+1
View File
@@ -338,6 +338,7 @@ func TestValidGroupName(t *testing.T) {
{"foo/..", false}, {"foo/..", false},
{"foo/./bar", false}, {"foo/./bar", false},
{"foo/../bar", false}, {"foo/../bar", false},
{"foo\\bar", false},
{"foo", true}, {"foo", true},
{"foo/bar", true}, {"foo/bar", true},
} }