diff options
author | cjihrig <cjihrig@gmail.com> | 2018-12-17 11:55:13 -0500 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2018-12-19 12:19:01 -0500 |
commit | bf36f0755c0a41702fe506bcfc90d156030d0497 (patch) | |
tree | c203c51148a167aa25d09ca93507f1437663953d /lib/internal/console/constructor.js | |
parent | 67f95825e5ad3f80d007613df8b21f4f2819c635 (diff) | |
download | android-node-v8-bf36f0755c0a41702fe506bcfc90d156030d0497.tar.gz android-node-v8-bf36f0755c0a41702fe506bcfc90d156030d0497.tar.bz2 android-node-v8-bf36f0755c0a41702fe506bcfc90d156030d0497.zip |
console: improve inspectOptions validation
This commit adds stricter type checking to the inspectOptions
option to the Console constructor.
PR-URL: https://github.com/nodejs/node/pull/25090
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/internal/console/constructor.js')
-rw-r--r-- | lib/internal/console/constructor.js | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js index c2cf1fc48c..7e1bcf802f 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -91,13 +91,15 @@ function Console(options /* or: stdout, stderr, ignoreErrors = true */) { if (typeof colorMode !== 'boolean' && colorMode !== 'auto') throw new ERR_INVALID_ARG_VALUE('colorMode', colorMode); - if (inspectOptions) { + if (typeof inspectOptions === 'object' && inspectOptions !== null) { if (inspectOptions.colors !== undefined && options.colorMode !== undefined) { throw new ERR_INCOMPATIBLE_OPTION_PAIR( 'inspectOptions.color', 'colorMode'); } optionsMap.set(this, inspectOptions); + } else if (inspectOptions !== undefined) { + throw new ERR_INVALID_ARG_TYPE('inspectOptions', 'object', inspectOptions); } // Bind the prototype functions to this Console instance |