zfs: check for forbidden dataset path characters

This commit is contained in:
Christian Schwarz 2017-05-01 20:09:17 +02:00
parent 301be177ea
commit 28f0b90c25

View File

@ -45,7 +45,10 @@ func NewDatasetPath(s string) (p DatasetPath, err error) {
if s == "" {
return EmptyDatasetPath, nil // the empty dataset path
}
// TODO validation
const FORBIDDEN = "@#|\t "
if strings.ContainsAny(s, FORBIDDEN) { // TODO space may be a bit too restrictive...
return nil, errors.New(fmt.Sprintf("path '%s' contains forbidden characters (any of '%s')", s, FORBIDDEN))
}
return toDatasetPath(s), nil
}