Skip to content

Commit 79a563d

Browse files
committed
Stop trimming preceding and suffixing spaces from editor filenames
In go-gitea#5702 it was decided to trim preceding and suffixed spaces aswell as / from editing file filenames. This was because at this point in time the url-safety of gitea was much poorer. We can now drop this requirement and file editing should work correctly. Fix go-gitea#18176 Signed-off-by: Andrew Thornton <[email protected]>
1 parent 531b6d6 commit 79a563d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

routers/web/repo/editor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ func UploadFilePost(ctx *context.Context) {
728728

729729
func cleanUploadFileName(name string) string {
730730
// Rebase the filename
731-
name = strings.Trim(path.Clean("/"+name), " /")
731+
name = strings.Trim(path.Clean("/"+name), "/")
732732
// Git disallows any filenames to have a .git directory in them.
733733
for _, part := range strings.Split(name, "/") {
734734
if strings.ToLower(part) == ".git" {

services/repository/files/file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func GetAuthorAndCommitterUsers(author, committer *IdentityOptions, doer *user_m
129129
// CleanUploadFileName Trims a filename and returns empty string if it is a .git directory
130130
func CleanUploadFileName(name string) string {
131131
// Rebase the filename
132-
name = strings.Trim(path.Clean("/"+name), " /")
132+
name = strings.Trim(path.Clean("/"+name), "/")
133133
// Git disallows any filenames to have a .git directory in them.
134134
for _, part := range strings.Split(name, "/") {
135135
if strings.ToLower(part) == ".git" {

0 commit comments

Comments
 (0)