Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-12-01 03:08:37 +0300
committerRuben Bridgewater <ruben@bridgewater.de>2019-12-07 02:38:29 +0300
commite11b909097e44a7acc77cf5f6e8be3016d3d4f6f (patch)
tree1683cbe8eb247d4784b60b789a1e76a8358d5371 /lib/internal/util
parentc430aebe8683699fc072cb87e5be03af370a3f2f (diff)
util: never trigger any proxy traps using `format()`
PR-URL: https://github.com/nodejs/node/pull/30767 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'lib/internal/util')
-rw-r--r--lib/internal/util/inspect.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js
index 4e6f967c6a8..a4a9a05ece9 100644
--- a/lib/internal/util/inspect.js
+++ b/lib/internal/util/inspect.js
@@ -1648,6 +1648,13 @@ function reduceToSingleString(
}
function hasBuiltInToString(value) {
+ // Prevent triggering proxy traps.
+ const getFullProxy = false;
+ const proxyTarget = getProxyDetails(value, getFullProxy);
+ if (proxyTarget !== undefined) {
+ value = proxyTarget;
+ }
+
// Count objects that have no `toString` function as built-in.
if (typeof value.toString !== 'function') {
return true;