From b116418f05b822481bba3613873eef876da73814 Mon Sep 17 00:00:00 2001 From: Lunny Xiao <xiaolunwen@gmail.com> Date: Wed, 8 Mar 2023 20:17:39 +0800 Subject: Use CleanPath instead of path.Clean (#23371) As title. --- modules/public/public.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/public/public.go') diff --git a/modules/public/public.go b/modules/public/public.go index 42026f9b10..e1d60d89eb 100644 --- a/modules/public/public.go +++ b/modules/public/public.go @@ -6,7 +6,6 @@ package public import ( "net/http" "os" - "path" "path/filepath" "strings" @@ -14,6 +13,7 @@ import ( "code.gitea.io/gitea/modules/httpcache" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/util" ) // Options represents the available options to configure the handler. @@ -103,7 +103,7 @@ func setWellKnownContentType(w http.ResponseWriter, file string) { func (opts *Options) handle(w http.ResponseWriter, req *http.Request, fs http.FileSystem, file string) bool { // use clean to keep the file is a valid path with no . or .. - f, err := fs.Open(path.Clean(file)) + f, err := fs.Open(util.CleanPath(file)) if err != nil { if os.IsNotExist(err) { return false -- cgit v1.2.3