1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Refactor editor (#34780)

A complete rewrite
This commit is contained in:
wxiaoguang
2025-06-21 19:20:51 +08:00
committed by GitHub
parent 81adb01713
commit 4fc626daa1
41 changed files with 977 additions and 1638 deletions

View File

@@ -134,9 +134,8 @@ func (err ErrFilenameInvalid) Unwrap() error {
return util.ErrInvalidArgument
}
// CleanUploadFileName Trims a filename and returns empty string if it is a .git directory
func CleanUploadFileName(name string) string {
// Rebase the filename
// CleanGitTreePath cleans a tree path for git, it returns an empty string the path is invalid (e.g.: contains ".git" part)
func CleanGitTreePath(name string) string {
name = util.PathJoinRel(name)
// Git disallows any filenames to have a .git directory in them.
for part := range strings.SplitSeq(name, "/") {
@@ -144,5 +143,8 @@ func CleanUploadFileName(name string) string {
return ""
}
}
if name == "." {
name = ""
}
return name
}