From e274a5777d62d20690394f528abceefa231ebde2 Mon Sep 17 00:00:00 2001 From: Jonathan Kingston Date: Thu, 22 Jun 2023 10:25:29 +0100 Subject: [PATCH] Short circuit hasTaintedMethod and reduce calling --- src/utils.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils.js b/src/utils.js index 1de5c6a06..881bf87d5 100644 --- a/src/utils.js +++ b/src/utils.js @@ -389,9 +389,13 @@ export function hasTaintedMethod (scope, shouldStackCheck = false) { if (!shouldStackCheck || !taintedOrigins()) { return false } + const currentTaintedOrigins = taintedOrigins() + if (!currentTaintedOrigins || currentTaintedOrigins.size === 0) { + return false + } const stackOrigins = getStackTraceOrigins(getStack()) for (const stackOrigin of stackOrigins) { - if (taintedOrigins()?.has(stackOrigin)) { + if (currentTaintedOrigins.has(stackOrigin)) { return true } }