Skip to content

Commit 0c3e581

Browse files
committed
Fix trimming of leading and trailing spaces when adding a new file
1 parent 00fc29a commit 0c3e581

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

routers/web/repo/editor.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,14 @@ func EditFilePost(ctx *context.Context) {
392392
// NewFilePost response for creating file
393393
func NewFilePost(ctx *context.Context) {
394394
form := web.GetForm(ctx).(*forms.EditRepoFileForm)
395+
396+
// trim leading and trailing spaces from the tree path
397+
treePath := strings.Split(form.TreePath, "/")
398+
for i, v := range treePath {
399+
treePath[i] = strings.TrimSpace(v)
400+
}
401+
form.TreePath = strings.Join(treePath, "/")
402+
395403
editFilePost(ctx, *form, true)
396404
}
397405

0 commit comments

Comments
 (0)