From c58fe49a903823c6c943de469dfdf562597d67df Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Tue, 9 Aug 2022 13:28:17 -0400 Subject: [PATCH] zip: fix bug with readdir and trailing slashes --- internal/fs/fs_zip.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/fs/fs_zip.go b/internal/fs/fs_zip.go index 5cb981c87a2..316abf92388 100644 --- a/internal/fs/fs_zip.go +++ b/internal/fs/fs_zip.go @@ -107,10 +107,14 @@ func tryToReadZipArchive(zipPath string, archive *zipFile) { // Handle a directory lowerDir := strings.ToLower(dirPath) if _, ok := dirs[lowerDir]; !ok { - dirs[lowerDir] = &compressedDir{ + dir := &compressedDir{ path: dirPath, entries: make(map[string]EntryKind), } + + // List the same directory both with and without the slash + dirs[lowerDir] = dir + dirs[lowerDir+"/"] = dir } } else { // Handle a file @@ -122,7 +126,10 @@ func tryToReadZipArchive(zipPath string, archive *zipFile) { path: dirPath, entries: make(map[string]EntryKind), } + + // List the same directory both with and without the slash dirs[lowerDir] = dir + dirs[lowerDir+"/"] = dir } dir.entries[baseName] = FileEntry } @@ -147,7 +154,10 @@ func tryToReadZipArchive(zipPath string, archive *zipFile) { path: dirPath, entries: make(map[string]EntryKind), } + + // List the same directory both with and without the slash dirs[lowerDir] = dir + dirs[lowerDir+"/"] = dir } dir.entries[baseName] = DirEntry baseName = dirPath