Skip to content

Commit

Permalink
bundle: Normalize paths before bundle root check
Browse files Browse the repository at this point in the history
filepath.Join can return paths with '\' separators. So
when this command is run on Windows the paths are joined
using '\'. But the bundle root check logic assumes the paths
are '/' separated. This change processes the result of filepath.Join
is ensure the path has '/' separators.

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
  • Loading branch information
ashutosh-narkar authored and srenatus committed Jul 13, 2022
1 parent db3a4e7 commit e6626cd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bundle/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,10 @@ func doDFS(obj map[string]json.RawMessage, path string, roots []string) error {

newPath := filepath.Join(strings.Trim(path, "/"), key)

// Note: filepath.Join can return paths with '\' separators, always use
// filepath.ToSlash to keep them normalized.
newPath = strings.TrimLeft(filepath.ToSlash(newPath), "/.")

contains := false
prefix := false
if RootPathsContain(roots, newPath) {
Expand Down

0 comments on commit e6626cd

Please sign in to comment.