Skip to content

Commit

Permalink
Improve set-constant scriptlet
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Jul 17, 2024
1 parent fd05417 commit 77feb25
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,8 @@ builtinScriptlets.push({
'safe-self.fn',
],
});
function validateConstantFn(trusted, raw) {
function validateConstantFn(trusted, raw, extraArgs = {}) {
const safe = safeSelf();
const extraArgs = safe.getExtraArgs(Array.from(arguments), 2);
let value;
if ( raw === 'undefined' ) {
value = undefined;
Expand Down Expand Up @@ -587,7 +586,7 @@ function setConstantFn(
};
if ( trappedProp === '' ) { return; }
const thisScript = document.currentScript;
let normalValue = validateConstantFn(trusted, rawValue);
let normalValue = validateConstantFn(trusted, rawValue, extraArgs);
if ( rawValue === 'noopFunc' || rawValue === 'trueFunc' || rawValue === 'falseFunc' ) {
normalValue = cloakFunc(normalValue);
}
Expand Down Expand Up @@ -4772,7 +4771,7 @@ function trustedReplaceArgument(
const logPrefix = safe.makeLogPrefix('trusted-replace-argument', propChain, argposRaw, argraw);
const argpos = parseInt(argposRaw, 10) || 0;
const extraArgs = safe.getExtraArgs(Array.from(arguments), 3);
const normalValue = validateConstantFn(true, argraw);
const normalValue = validateConstantFn(true, argraw, extraArgs);
const reCondition = extraArgs.condition
? safe.patternToRegex(extraArgs.condition)
: /^/;
Expand Down

0 comments on commit 77feb25

Please sign in to comment.