-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
Description
- There are two
cleanUploadFileName
functions - The spaces in filenames are trimmed
- 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
gitea/routers/web/repo/editor.go
Lines 733 to 743 in ff2fd08
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 | |
} |
gitea/services/repository/files/file.go
Lines 129 to 140 in 719bddc
// 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 | |
} |