try to protect
parent
fa9aafcd28
commit
ea1c5b982c
|
|
@ -249,6 +249,9 @@ func (server *Server) apiV0FilesPostHandler(w http.ResponseWriter, r *http.Reque
|
|||
|
||||
func (server *Server) apiV0FilesIDGetHandler(w http.ResponseWriter, r *http.Request) error {
|
||||
id := server.fileId(r)
|
||||
if len(id) == 0 || id[0] == "" {
|
||||
return fmt.Errorf("no id found: %+v", id)
|
||||
}
|
||||
|
||||
leaf, err := server.tree().Get(id)
|
||||
if os.IsNotExist(err) {
|
||||
|
|
@ -265,6 +268,9 @@ func (server *Server) apiV0FilesIDGetHandler(w http.ResponseWriter, r *http.Requ
|
|||
|
||||
func (server *Server) apiV0FilesIDDelHandler(w http.ResponseWriter, r *http.Request) error {
|
||||
id := server.fileId(r)
|
||||
if len(id) == 0 || id[0] == "" {
|
||||
return fmt.Errorf("no id found: %+v", id)
|
||||
}
|
||||
|
||||
leaf, err := server.tree().Get(id)
|
||||
if os.IsNotExist(err) {
|
||||
|
|
@ -290,16 +296,21 @@ func (server *Server) urlFileId(id []string) string {
|
|||
|
||||
func (server *Server) fileId(r *http.Request) []string {
|
||||
return strings.Split(
|
||||
strings.TrimPrefix(
|
||||
strings.TrimPrefix(
|
||||
strings.Trim(r.URL.Path, "/"),
|
||||
"api/v0/files/",
|
||||
"api/v0/files",
|
||||
),
|
||||
"/"),
|
||||
"/",
|
||||
)
|
||||
}
|
||||
|
||||
func (server *Server) apiV0FilesIDPutHandler(w http.ResponseWriter, r *http.Request) error {
|
||||
id := server.fileId(r)
|
||||
if len(id) == 0 || id[0] == "" {
|
||||
return fmt.Errorf("no id found: %+v", id)
|
||||
}
|
||||
|
||||
leaf, err := server.tree().Get(id)
|
||||
if os.IsNotExist(err) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue