Skip to content

Commit 0c3f950

Browse files
6543zeripathlafriks
authored
Use path not filepath in routers/editor (#14390) (#14396)
The incorrect use of filepath instead of path means that it is possible to cause a stackoverflow on Windows Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: zeripath <[email protected]> Co-authored-by: Lauris BH <[email protected]>
1 parent 4583caa commit 0c3f950

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

routers/repo/editor.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"fmt"
1010
"io/ioutil"
1111
"path"
12-
"path/filepath"
1312
"strings"
1413

1514
"code.gitea.io/gitea/models"
@@ -502,7 +501,7 @@ func DeleteFilePost(ctx *context.Context, form auth.DeleteRepoFileForm) {
502501
if form.CommitChoice == frmCommitChoiceNewBranch && ctx.Repo.Repository.UnitEnabled(models.UnitTypePullRequests) {
503502
ctx.Redirect(ctx.Repo.RepoLink + "/compare/" + ctx.Repo.BranchName + "..." + form.NewBranchName)
504503
} else {
505-
treePath := filepath.Dir(ctx.Repo.TreePath)
504+
treePath := path.Dir(ctx.Repo.TreePath)
506505
if treePath == "." {
507506
treePath = "" // the file deleted was in the root, so we return the user to the root directory
508507
}
@@ -805,10 +804,10 @@ func GetClosestParentWithFiles(treePath string, commit *git.Commit) string {
805804
// see if the tree has entries
806805
if tree, err := commit.SubTree(treePath); err != nil {
807806
// failed to get tree, going up a dir
808-
return GetClosestParentWithFiles(filepath.Dir(treePath), commit)
807+
return GetClosestParentWithFiles(path.Dir(treePath), commit)
809808
} else if entries, err := tree.ListEntries(); err != nil || len(entries) == 0 {
810809
// no files in this dir, going up a dir
811-
return GetClosestParentWithFiles(filepath.Dir(treePath), commit)
810+
return GetClosestParentWithFiles(path.Dir(treePath), commit)
812811
}
813812
return treePath
814813
}

0 commit comments

Comments
 (0)