Modify the file name with spaces and cannot be deleted
This commit is contained in:
parent
60b3497005
commit
dbb0de14cc
|
@ -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" {
|
||||
|
|
|
@ -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" {
|
||||
|
|
Loading…
Reference in New Issue