Skip to content

Commit

Permalink
fix(http): make sure invalid formidable files are skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
marcj committed Apr 4, 2024
1 parent 015d90a commit d1ff09b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/http/src/request-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,17 @@ function parseBody(
reject(err);
} else {
for (const [name, file] of Object.entries(files) as any) {
if (file.size === 0) continue;
if (!file.filepath || 'string' !== typeof file.filepath) continue;
if (!file.size || 'number' !== typeof file.size) continue;
if (file.lastModifiedDate && !(file.lastModifiedDate instanceof Date)) continue;

foundFiles[name] = {
validator: UploadedFileSymbol,
size: file.size,
path: file.filepath,
name: file.originalFilename,
type: file.mimetype,
lastModifiedDate: file.lastModifiedDate,
name: file.originalFilename || null,
type: file.mimetype || null,
lastModifiedDate: file.lastModifiedDate || null,
};
}
const body = { ...fields, ...foundFiles };
Expand Down

0 comments on commit d1ff09b

Please sign in to comment.