Fix trimming of leading and trailing spaces when adding a new file

This commit is contained in:
charles 2024-06-27 09:49:02 +08:00 committed by charles7668
parent f0033051d5
commit f34a0b9f32

View File

@ -392,6 +392,14 @@ func EditFilePost(ctx *context.Context) {
// NewFilePost response for creating file
func NewFilePost(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.EditRepoFileForm)
// trim leading and trailing spaces from the tree path
treePath := strings.Split(form.TreePath, "/")
for i, v := range treePath {
treePath[i] = strings.TrimSpace(v)
}
form.TreePath = strings.Join(treePath, "/")
editFilePost(ctx, *form, true)
}