Skip to content

Commit 6b0a712

Browse files
authored
Stop trimming preceding and suffixing spaces from editor filenames (#18334)
* Stop trimming preceding and suffixing spaces from editor filenames In #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 #18176 Signed-off-by: Andrew Thornton <[email protected]>
1 parent c68f128 commit 6b0a712

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ been added to each release, please refer to the [blog](https://blog.gitea.io).
228228
* Add left padding for chunk header of split diff view (#13397)
229229
* Allow U2F 2FA without TOTP (#11573)
230230
* BUGFIXES
231+
* Stop trimming preceding and suffixing spaces from editor filenames (#18334)
231232
* Restore propagation of ErrDependenciesLeft (#18325)
232233
* Fix PR comments UI (#18323)
233234
* Use indirect comparison when showing pull requests (#18313)

routers/web/repo/editor.go

+1-1
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

+1-1
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)