diff options
author | zeripath <art27@cantab.net> | 2021-01-18 23:20:10 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-19 00:20:10 +0100 |
commit | b59ed41e81270660e08a18ade5ad09ecd033f905 (patch) | |
tree | 5678551d92e7a131b356fd62973fa1a551c82211 | |
parent | 6ff63c82025099b5fd10f47f211104d839a39977 (diff) | |
download | gitea-b59ed41e81270660e08a18ade5ad09ecd033f905.tar.gz gitea-b59ed41e81270660e08a18ade5ad09ecd033f905.zip |
Use path not filepath in routers/editor (#14390)
The incorrect use of filepath instead of path means that
it is possible to cause a stackoverflow on Windows
Signed-off-by: Andrew Thornton <art27@cantab.net>
-rw-r--r-- | routers/repo/editor.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/routers/repo/editor.go b/routers/repo/editor.go index afb6605dc3..0bc76504f9 100644 --- a/routers/repo/editor.go +++ b/routers/repo/editor.go @@ -9,7 +9,6 @@ import ( "fmt" "io/ioutil" "path" - "path/filepath" "strings" "code.gitea.io/gitea/models" @@ -502,7 +501,7 @@ func DeleteFilePost(ctx *context.Context, form auth.DeleteRepoFileForm) { if form.CommitChoice == frmCommitChoiceNewBranch && ctx.Repo.Repository.UnitEnabled(models.UnitTypePullRequests) { ctx.Redirect(ctx.Repo.RepoLink + "/compare/" + util.PathEscapeSegments(ctx.Repo.BranchName) + "..." + util.PathEscapeSegments(form.NewBranchName)) } else { - treePath := filepath.Dir(ctx.Repo.TreePath) + treePath := path.Dir(ctx.Repo.TreePath) if treePath == "." { treePath = "" // the file deleted was in the root, so we return the user to the root directory } @@ -805,10 +804,10 @@ func GetClosestParentWithFiles(treePath string, commit *git.Commit) string { // see if the tree has entries if tree, err := commit.SubTree(treePath); err != nil { // failed to get tree, going up a dir - return GetClosestParentWithFiles(filepath.Dir(treePath), commit) + return GetClosestParentWithFiles(path.Dir(treePath), commit) } else if entries, err := tree.ListEntries(); err != nil || len(entries) == 0 { // no files in this dir, going up a dir - return GetClosestParentWithFiles(filepath.Dir(treePath), commit) + return GetClosestParentWithFiles(path.Dir(treePath), commit) } return treePath } |