added base path filter
This commit is contained in:
parent
98b53d3a33
commit
ec5a376733
15 changed files with 104 additions and 44 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue