Skip to content

Commit 8e60aa5

Browse files
committed
add a handler for when windows volume path like 'C:'
1 parent c8e05a8 commit 8e60aa5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

kyaml/filesys/fsnode.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,18 @@ func (n *fsNode) Path() string {
101101
// result of filepath.Split.
102102
func mySplit(s string) (string, string) {
103103
dName, fName := filepath.Split(s)
104-
return StripTrailingSeps(dName), fName
104+
dName = StripTrailingSeps(dName)
105+
106+
// Prevent infinite recursion on Windows when dealing with volume names
107+
// or paths that don't split properly. If after stripping separators,
108+
// dName is the same as the input s, it means filepath.Split didn't
109+
// actually split anything meaningful (e.g., "C:" on Windows).
110+
// In this case, treat the entire string as the filename.
111+
if dName == s {
112+
return "", s
113+
}
114+
115+
return dName, fName
105116
}
106117

107118
func (n *fsNode) addFile(name string, c []byte) (result *fsNode, err error) {

0 commit comments

Comments
 (0)