diff --git a/modules/repofiles/repofiles.go b/modules/repofiles/repofiles.go index 1fc900490..51b26f86a 100644 --- a/modules/repofiles/repofiles.go +++ b/modules/repofiles/repofiles.go @@ -1,3 +1,10 @@ +/* + * @Descripttion: + * @Author: hang + * @version: + * @Date: 2021-10-28 18:21:53 + * @LastEditors: hang + */ // Copyright 2019 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file.package repofiles @@ -12,7 +19,7 @@ import ( // CleanUploadFileName Trims a filename and returns empty string if it is a .git directory func CleanUploadFileName(name string) string { // Rebase the filename - name = strings.Trim(path.Clean("/"+name), " /") + name = strings.Trim(path.Clean("/"+name), "/") // Git disallows any filenames to have a .git directory in them. for _, part := range strings.Split(name, "/") { if strings.ToLower(part) == ".git" { diff --git a/routers/web/repo/editor.go b/routers/web/repo/editor.go index f7a877834..f2ca8b40c 100644 --- a/routers/web/repo/editor.go +++ b/routers/web/repo/editor.go @@ -727,7 +727,7 @@ func UploadFilePost(ctx *context.Context) { func cleanUploadFileName(name string) string { // Rebase the filename - name = strings.Trim(path.Clean("/"+name), " /") + name = strings.Trim(path.Clean("/"+name), "/") // Git disallows any filenames to have a .git directory in them. for _, part := range strings.Split(name, "/") { if strings.ToLower(part) == ".git" {