fs: validate falsy openAsBlob type option · nodejs/node@8b24247 · GitHub
Skip to content

Commit 8b24247

Browse files
christianaurichzmaduh95
authored andcommitted
fs: validate falsy openAsBlob type option
openAsBlob() and openAsBlobSync() read the MIME type as options.type || '' before validating it, causing falsy non-string values to be replaced with the default before reaching validateString(). As a result, { type: 0 }, { type: false }, { type: null }, and { type: NaN } are accepted as an empty type, while { type: 1 } throws ERR_INVALID_ARG_TYPE. Default the option only when it is undefined so all other values are validated against the documented string type. Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com> PR-URL: #66125 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 51daf16 commit 8b24247

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

‎lib/fs.js‎

Lines changed: 2 additions & 2 deletions

‎test/parallel/test-fs-openAsBlobSync.js‎

Lines changed: 8 additions & 3 deletions

0 commit comments

Comments
 (0)