forked from Gitlink/gitea-1156
修复文件名前缀带空格不能编辑和删除问题
This commit is contained in:
commit
d59fbd0053
|
@ -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.
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a MIT-style
|
// Use of this source code is governed by a MIT-style
|
||||||
// license that can be found in the LICENSE file.package repofiles
|
// 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
|
// CleanUploadFileName Trims a filename and returns empty string if it is a .git directory
|
||||||
func CleanUploadFileName(name string) string {
|
func CleanUploadFileName(name string) string {
|
||||||
// Rebase the filename
|
// 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.
|
// Git disallows any filenames to have a .git directory in them.
|
||||||
for _, part := range strings.Split(name, "/") {
|
for _, part := range strings.Split(name, "/") {
|
||||||
if strings.ToLower(part) == ".git" {
|
if strings.ToLower(part) == ".git" {
|
||||||
|
|
|
@ -727,7 +727,7 @@ func UploadFilePost(ctx *context.Context) {
|
||||||
|
|
||||||
func cleanUploadFileName(name string) string {
|
func cleanUploadFileName(name string) string {
|
||||||
// Rebase the filename
|
// 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.
|
// Git disallows any filenames to have a .git directory in them.
|
||||||
for _, part := range strings.Split(name, "/") {
|
for _, part := range strings.Split(name, "/") {
|
||||||
if strings.ToLower(part) == ".git" {
|
if strings.ToLower(part) == ".git" {
|
||||||
|
|
Loading…
Reference in New Issue