summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-10-03 02:38:37 +0200
committerRich Trott <rtrott@gmail.com>2019-10-10 21:36:20 -0700
commit2664dacf7e0e13dc24485836e66081fb07ee1289 (patch)
tree38443f5af4bee045c4d9861f84c1e0c2f08c763c /lib
parent3aeae8d81b7b78668c37f7a07a72d94781126d49 (diff)
downloadandroid-node-v8-2664dacf7e0e13dc24485836e66081fb07ee1289.tar.gz
android-node-v8-2664dacf7e0e13dc24485836e66081fb07ee1289.tar.bz2
android-node-v8-2664dacf7e0e13dc24485836e66081fb07ee1289.zip
util: validate formatWithOptions inspectOptions
This makes sure that the `inspectOptions` are validated. This could otherwise cause confusion. Fixes: https://github.com/nodejs/node/issues/29726 PR-URL: https://github.com/nodejs/node/pull/29824 Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/util/inspect.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js
index 39cbfd36b7..2f922f6659 100644
--- a/lib/internal/util/inspect.js
+++ b/lib/internal/util/inspect.js
@@ -1542,11 +1542,6 @@ function reduceToSingleString(
return `${braces[0]}${ln}${join(output, `,\n${indentation} `)} ${braces[1]}`;
}
-function format(...args) {
- return formatWithOptions(undefined, ...args);
-}
-
-
const firstErrorLine = (error) => error.message.split('\n')[0];
let CIRCULAR_ERROR_MESSAGE;
function tryStringify(arg) {
@@ -1569,7 +1564,19 @@ function tryStringify(arg) {
}
}
+function format(...args) {
+ return formatWithOptionsInternal(undefined, ...args);
+}
+
function formatWithOptions(inspectOptions, ...args) {
+ if (typeof inspectOptions !== 'object' || inspectOptions === null) {
+ throw new ERR_INVALID_ARG_TYPE(
+ 'inspectOptions', 'object', inspectOptions);
+ }
+ return formatWithOptionsInternal(inspectOptions, ...args);
+}
+
+function formatWithOptionsInternal(inspectOptions, ...args) {
const first = args[0];
let a = 0;
let str = '';