added base path filter

This commit is contained in:
ston1th 2019-05-03 10:44:17 +02:00
commit ec5a376733
15 changed files with 104 additions and 44 deletions

View file

@ -1,6 +1,11 @@
package fs
import "path/filepath"
import (
"errors"
"git.giftfish.de/ston1th/docstore/pkg/core"
"path/filepath"
"strings"
)
const sep = "/"
@ -12,3 +17,27 @@ func File(path string) string {
_, f := filepath.Split(Clean(path))
return f
}
var reserved = []string{
core.TotpURI,
core.LoginURI,
core.LogoutURI,
core.RawPrefix,
core.IndexPrefix,
core.UploadPrefix,
core.NewPrefix,
core.MovePrefix,
core.DeletePrefix,
core.Favicon,
core.BootstrapCSS,
core.CustomCSS,
}
func checkPath(path string) error {
for _, p := range reserved {
if strings.HasPrefix(path, p) {
return errors.New("base path '" + p + "' is reserved")
}
}
return nil
}