From e6626cd2c6b43f197baa813eefdbdfe6503c33af Mon Sep 17 00:00:00 2001 From: Ashutosh Narkar Date: Mon, 11 Jul 2022 10:45:29 -0700 Subject: [PATCH] bundle: Normalize paths before bundle root check 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 --- bundle/store.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bundle/store.go b/bundle/store.go index 247617df57..4bb12c1179 100644 --- a/bundle/store.go +++ b/bundle/store.go @@ -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) {