Scriptlets icon indicating copy to clipboard operation
Scriptlets copied to clipboard

Fix 'set-constant' and 'trusted-set-constant' — stack matching does not work correctly

Open AdamWr opened this issue 7 months ago • 0 comments

It seems that currently stack parameter doesn't work correctly, it's checked at the beginning of the scriptlet: https://github.com/AdguardTeam/Scriptlets/blob/3ba245f96237915bbff6fe80c7400b03c0f5014d/src/scriptlets/set-constant.js#L163-L166 not when value is set/get.

Similar to - https://github.com/AdguardTeam/Scriptlets/issues/348

Steps to reproduce:

  1. Add this rule:
example.org#%#//scriptlet('set-constant', 'alert', 'trueFunc', 'test')
  1. Go to - https://example.org/
  2. Run in console:
const test = (arg = 'test') => {
  console.log(new Error().stack);
  alert(arg);
};
test();

alert is displayed.

AdamWr avatar May 05 '25 16:05 AdamWr