From 764ba707a28f8f0737dceea151f31e9fed50a0f2 Mon Sep 17 00:00:00 2001 From: blam Date: Mon, 25 Jul 2022 13:53:54 +0200 Subject: [PATCH] chore: refactor and comment Signed-off-by: blam --- .changeset/nine-mails-crash.md | 2 +- packages/backend-common/src/reading/tree/ZipArchiveResponse.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.changeset/nine-mails-crash.md b/.changeset/nine-mails-crash.md index ecb047802e..ead5553d1c 100644 --- a/.changeset/nine-mails-crash.md +++ b/.changeset/nine-mails-crash.md @@ -6,4 +6,4 @@ The `ZipArchiveResponse` now correctly handles corrupt ZIP archives. Before this change, certain corrupt ZIP archives either cause the inflater to throw (as expected), or will hang the parser indefinitely. -By switching out the `zip` parsing library, we now write to a temporary directory, and load from disk which should ensure that the parsing of the `.zip` files are done correctly because `streaming` of `zip` paths is technically impossible without being able to parse the headers at the end of he file. +By switching out the `zip` parsing library, we now write to a temporary directory, and load from disk which should ensure that the parsing of the `.zip` files are done correctly because `streaming` of `zip` paths is technically impossible without being able to parse the headers at the end of the file. diff --git a/packages/backend-common/src/reading/tree/ZipArchiveResponse.ts b/packages/backend-common/src/reading/tree/ZipArchiveResponse.ts index b25f6ad24e..1a6658b0c2 100644 --- a/packages/backend-common/src/reading/tree/ZipArchiveResponse.ts +++ b/packages/backend-common/src/reading/tree/ZipArchiveResponse.ts @@ -111,7 +111,8 @@ export class ZipArchiveResponse implements ReadTreeResponse { } zipfile.on('entry', async (entry: Entry) => { - if (!/\/$/.test(entry.fileName) && this.shouldBeIncluded(entry)) { + // Check that the file is not a directory, and that is matches the filter. + if (!entry.fileName.endsWith('/') && this.shouldBeIncluded(entry)) { zipfile.openReadStream(entry, async (openErr, readStream) => { if (openErr || !readStream) { reject(