Skip to content

Fix 'trusted-replace-argument' — when 'replace:' options is used and 'argument` is not a string then it's incorrectly replaced #570

Description

@AdamWr

Steps to reproduce:

  1. Add to user rules:
example.org#%#//scriptlet('trusted-replace-argument', 'Element.prototype.setAttribute', '1', 'replace:/whatever/test/g')
  1. Navigate to https://example.org/
  2. Run in console:
const h1 = document.querySelector('h1');
const value = 1234;
h1.setAttribute('data-attr', value);
console.log(h1.getAttribute('data-attr'));

It should logs 1234 in console, but content is replaced and it logs test.
When value is a string ('1234') then it works correctly.

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions