Commit 7f93a496 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Forbid backslashes in group names.

We used to only forbid them under Windows.
parent 41076461
...@@ -420,10 +420,14 @@ func Add(name string, desc *Description) (*Group, error) { ...@@ -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 == "/" {
......
...@@ -338,6 +338,7 @@ func TestValidGroupName(t *testing.T) { ...@@ -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},
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment