From 06e15fc149fc86a82d04dda12f59e167b92ad5b7 Mon Sep 17 00:00:00 2001 From: Noah Hsu Date: Fri, 12 Aug 2022 14:51:23 +0800 Subject: [PATCH] feat: encode path of url (close #1351) --- server/handles/down.go | 2 +- server/handles/fsmanage.go | 2 +- server/handles/fsread.go | 2 +- server/webdav/webdav.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/handles/down.go b/server/handles/down.go index 86217b2c87f..eb9d04a474a 100644 --- a/server/handles/down.go +++ b/server/handles/down.go @@ -55,7 +55,7 @@ func Proxy(c *gin.Context) { if ok { URL := fmt.Sprintf("%s%s?sign=%s", strings.Split(downProxyUrl, "\n")[0], - utils.EncodePath(rawPath), + utils.EncodePath(rawPath, true), sign.Sign(filename)) c.Redirect(302, URL) return diff --git a/server/handles/fsmanage.go b/server/handles/fsmanage.go index c8f6af8fbea..2649a82abb4 100644 --- a/server/handles/fsmanage.go +++ b/server/handles/fsmanage.go @@ -248,7 +248,7 @@ func Link(c *gin.Context) { common.SuccessResp(c, model.Link{ URL: fmt.Sprintf("%s/p%s?d&sign=%s", common.GetApiUrl(c.Request), - utils.EncodePath(req.Path), + utils.EncodePath(req.Path, true), sign.Sign(stdpath.Base(rawPath))), }) return diff --git a/server/handles/fsread.go b/server/handles/fsread.go index 899752bc4ff..c8a10999fc3 100644 --- a/server/handles/fsread.go +++ b/server/handles/fsread.go @@ -250,7 +250,7 @@ func FsGet(c *gin.Context) { } else { rawURL = fmt.Sprintf("%s/p%s?sign=%s", common.GetApiUrl(c.Request), - utils.EncodePath(req.Path), + utils.EncodePath(req.Path, true), sign.Sign(obj.GetName())) } } else { diff --git a/server/webdav/webdav.go b/server/webdav/webdav.go index f43f500c065..eb7d49d2dd9 100644 --- a/server/webdav/webdav.go +++ b/server/webdav/webdav.go @@ -230,7 +230,7 @@ func (h *Handler) handleGetHeadPost(w http.ResponseWriter, r *http.Request) (sta } else if storage.Config().MustProxy() || storage.GetStorage().WebdavProxy() { u := fmt.Sprintf("%s/p%s?sign=%s", common.GetApiUrl(r), - utils.EncodePath(reqPath), + utils.EncodePath(reqPath, true), sign.Sign(path.Base(reqPath))) http.Redirect(w, r, u, 302) } else {