Skip to content

Commit

Permalink
fix: allows empty file to bypass filetype check
Browse files Browse the repository at this point in the history
  • Loading branch information
mathewmeconry committed Nov 9, 2023
1 parent f62861d commit 9c557d3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/middlewares/pin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ export function pinRouteMiddlware(
undefined,
{ responseType: "arraybuffer" }
);

if (Buffer.from(response.data).byteLength === 0) {
logger.info(
`Buffer is empty. allowing it and ignoring the mime type check`
);
next();
return;
}

const allowed = await isAllowedMimeType(response.data, allowedMimeTypes);
if (!allowed) {
res.contentType("text").status(400).send("File type not allowed");
Expand Down

0 comments on commit 9c557d3

Please sign in to comment.