diff --git a/fileserver/fileop.go b/fileserver/fileop.go index 1806aad..b43ff24 100644 --- a/fileserver/fileop.go +++ b/fileserver/fileop.go @@ -235,14 +235,12 @@ func parseCryptKey(rsp http.ResponseWriter, repoID string, user string, version func accessV2CB(rsp http.ResponseWriter, r *http.Request) *appError { vars := mux.Vars(r) repoID := vars["repoid"] + filePath := vars["filepath"] - filePath := r.URL.Query().Get("p") - op := r.URL.Query().Get("op") if filePath == "" { msg := "No file path\n" return &appError{nil, msg, http.StatusBadRequest} } - decPath, err := url.PathUnescape(filePath) if err != nil { msg := fmt.Sprintf("File path %s can't be decoded\n", filePath) @@ -251,6 +249,7 @@ func accessV2CB(rsp http.ResponseWriter, r *http.Request) *appError { rpath := getCanonPath(decPath) fileName := filepath.Base(rpath) + op := r.URL.Query().Get("op") if op != "view" && op != "download" { msg := "Operation is neither view or download\n" return &appError{nil, msg, http.StatusBadRequest} diff --git a/fileserver/fileserver.go b/fileserver/fileserver.go index d2929d8..4b2de22 100644 --- a/fileserver/fileserver.go +++ b/fileserver/fileserver.go @@ -470,7 +470,7 @@ func newHTTPRouter() *mux.Router { r.Handle("/f/{.*}{slash:\\/?}", appHandler(accessLinkCB)) //r.Handle("/d/{.*}", appHandler(accessDirLinkCB)) - r.Handle("/repos/{repoid:[\\da-z]{8}-[\\da-z]{4}-[\\da-z]{4}-[\\da-z]{4}-[\\da-z]{12}}/files{slash:\\/?}", appHandler(accessV2CB)) + r.Handle("/repos/{repoid:[\\da-z]{8}-[\\da-z]{4}-[\\da-z]{4}-[\\da-z]{4}-[\\da-z]{12}}/files/{filepath:.*}", appHandler(accessV2CB)) // file syncing api r.Handle("/repo/{repoid:[\\da-z]{8}-[\\da-z]{4}-[\\da-z]{4}-[\\da-z]{4}-[\\da-z]{12}}/permission-check{slash:\\/?}", diff --git a/server/access-file.c b/server/access-file.c index 918197b..b76f4cc 100644 --- a/server/access-file.c +++ b/server/access-file.c @@ -1500,8 +1500,8 @@ access_v2_cb(evhtp_request_t *req, void *arg) GError *error = NULL; /* Skip the first '/'. */ - char **parts = g_strsplit (req->uri->path->full + 1, "/", 0); - if (!parts || g_strv_length (parts) < 3 || + char **parts = g_strsplit (req->uri->path->full + 1, "/", 4); + if (!parts || g_strv_length (parts) < 4 || strcmp (parts[2], "files") != 0) { error_str = "Invalid URL\n"; goto out; @@ -1509,7 +1509,7 @@ access_v2_cb(evhtp_request_t *req, void *arg) repo_id = parts[1]; - path = evhtp_kv_find (req->uri->query, "p"); + path = parts[3]; if (!path) { error_str = "No file path\n"; goto out;