diff options
author | Paulo Gomes <pjbgf@linux.com> | 2024-03-06 18:31:33 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-06 18:31:33 +0000 |
commit | efdd3995a97305ade02e482ef99f8b989b5ef55f (patch) | |
tree | cee04e7a2e7a5083b06d25c0081b35d490f75544 /worktree.go | |
parent | 8d007039aba42c77964cdcb14dd8b86ccabb3469 (diff) | |
parent | 384dbf730bc337ff66a2705af707d12a515eca9e (diff) | |
download | go-git-efdd3995a97305ade02e482ef99f8b989b5ef55f.tar.gz |
Merge pull request #1042 from tim775/fix/worktree_valid_path_panic
git: worktree, Don't panic on empty or root path when checking if it is valid
Diffstat (limited to 'worktree.go')
-rw-r--r-- | worktree.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/worktree.go b/worktree.go index 4dfe036..ab11d42 100644 --- a/worktree.go +++ b/worktree.go @@ -428,6 +428,10 @@ var worktreeDeny = map[string]struct{}{ func validPath(paths ...string) error { for _, p := range paths { parts := strings.FieldsFunc(p, func(r rune) bool { return (r == '\\' || r == '/') }) + if len(parts) == 0 { + return fmt.Errorf("invalid path: %q", p) + } + if _, denied := worktreeDeny[strings.ToLower(parts[0])]; denied { return fmt.Errorf("invalid path prefix: %q", p) } |