Hopefully fix #
This commit is contained in:
@@ -10,6 +10,7 @@ package filemanager
|
||||
import (
|
||||
e "errors"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/hacdias/caddy-filemanager/assets"
|
||||
@@ -64,7 +65,7 @@ func (f FileManager) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, err
|
||||
}
|
||||
|
||||
// Checks if the request URL is for the WebDav server
|
||||
if httpserver.Path(r.URL.Path).Matches(c.WebDavURL) {
|
||||
if httpserver.Path(r.URL.Path).Matches(c.BaseURL + c.WebDavURL) {
|
||||
// Checks for user permissions relatively to this PATH
|
||||
if !user.Allowed(strings.TrimPrefix(r.URL.Path, c.WebDavURL)) {
|
||||
return http.StatusForbidden, nil
|
||||
@@ -83,6 +84,17 @@ func (f FileManager) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, err
|
||||
|
||||
// Preprocess the PUT request if it's the case
|
||||
if r.Method == http.MethodPut {
|
||||
var urlp *url.URL
|
||||
urlp, err = url.Parse(strings.Replace(r.URL.String(), c.WebDavURL, "", 1))
|
||||
if err != nil {
|
||||
return code, err
|
||||
}
|
||||
|
||||
fi, code, err = file.GetInfo(urlp, c, user)
|
||||
if err != nil {
|
||||
return code, err
|
||||
}
|
||||
|
||||
if handlers.PreProccessPUT(w, r, c, user, fi) != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user