From 1dee8ae49fa92b7bf1a8b1fd5f62173f92a413f5 Mon Sep 17 00:00:00 2001 From: Zeng1998 <1129142694@qq.com> Date: Mon, 12 Dec 2022 20:00:21 +0800 Subject: [PATCH] fix: url resource filename decode (#738) * fix: url resource filename decode * update * update Co-authored-by: boojack Co-authored-by: boojack --- server/resource.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/resource.go b/server/resource.go index e2c77995..bbf009ed 100644 --- a/server/resource.go +++ b/server/resource.go @@ -3,9 +3,9 @@ package server import ( "encoding/json" "fmt" - "html" "io" "net/http" + "net/url" "strconv" "time" @@ -249,8 +249,10 @@ func (s *Server) registerResourcePublicRoutes(g *echo.Group) { if err != nil { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("resourceId"))).SetInternal(err) } - - filename := html.UnescapeString(c.Param("filename")) + filename, err := url.QueryUnescape(c.Param("filename")) + if err != nil { + return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("filename is invalid: %s", c.Param("filename"))).SetInternal(err) + } resourceFind := &api.ResourceFind{ ID: &resourceID, Filename: &filename,