Skip to content

Commit 461a5d9

Browse files
committed
fix: Ignore the relative path in zip instead of throwing error
1 parent 17744fe commit 461a5d9

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

packages/system/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ export async function openFileSystem(basePath: string | Uint8Array): Promise<Fil
2828
// absolute path convert to relative path
2929
e.fileName = fileName.replace(/^[a-zA-Z]:/, '').replace(/^\//, '')
3030
}
31-
if (fileName.split("/").indexOf("..") !== -1) {
32-
return "invalid relative path: " + fileName;
33-
}
34-
// all good
3531
return null;
3632
},
3733
})
38-
const entries = await readAllEntries(zip)
34+
const entries = await readAllEntries(zip).then(es =>
35+
// ignore entries with '..' in the path
36+
es.filter(e => e.fileName.split("/").indexOf("..") === -1)
37+
)
3938
const entriesRecord: Record<string, Entry> = {}
4039
for (const entry of entries) {
4140
entriesRecord[entry.fileName] = entry

0 commit comments

Comments
 (0)