Skip to content

Can not edit/delete a file when its name starts with spaces #18176

Closed
@wxiaoguang

Description

@wxiaoguang
  1. There are two cleanUploadFileName functions
  2. The spaces in filenames are trimmed
  3. If a file name starts with space eg: decode(%20a.txt), then it can not be edited/deleted from the web UI

@zeripath do you have any idea about why the spaces are trimmed? this change was introduced by #5702

func cleanUploadFileName(name string) string {
// Rebase the filename
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" {
return ""
}
}
return name
}

// 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), " /")
// Git disallows any filenames to have a .git directory in them.
for _, part := range strings.Split(name, "/") {
if strings.ToLower(part) == ".git" {
return ""
}
}
return name
}

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions