Skip to content

Commit c58fe49

Browse files
committed
zip: fix bug with readdir and trailing slashes
1 parent 4f43888 commit c58fe49

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

internal/fs/fs_zip.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,14 @@ func tryToReadZipArchive(zipPath string, archive *zipFile) {
107107
// Handle a directory
108108
lowerDir := strings.ToLower(dirPath)
109109
if _, ok := dirs[lowerDir]; !ok {
110-
dirs[lowerDir] = &compressedDir{
110+
dir := &compressedDir{
111111
path: dirPath,
112112
entries: make(map[string]EntryKind),
113113
}
114+
115+
// List the same directory both with and without the slash
116+
dirs[lowerDir] = dir
117+
dirs[lowerDir+"/"] = dir
114118
}
115119
} else {
116120
// Handle a file
@@ -122,7 +126,10 @@ func tryToReadZipArchive(zipPath string, archive *zipFile) {
122126
path: dirPath,
123127
entries: make(map[string]EntryKind),
124128
}
129+
130+
// List the same directory both with and without the slash
125131
dirs[lowerDir] = dir
132+
dirs[lowerDir+"/"] = dir
126133
}
127134
dir.entries[baseName] = FileEntry
128135
}
@@ -147,7 +154,10 @@ func tryToReadZipArchive(zipPath string, archive *zipFile) {
147154
path: dirPath,
148155
entries: make(map[string]EntryKind),
149156
}
157+
158+
// List the same directory both with and without the slash
150159
dirs[lowerDir] = dir
160+
dirs[lowerDir+"/"] = dir
151161
}
152162
dir.entries[baseName] = DirEntry
153163
baseName = dirPath

0 commit comments

Comments
 (0)