Skip to content

Adding a big script into Brave scriptlets will throw maximum stack exceeded error in settings.js #51448

@gnekich

Description

@gnekich

Description

Saving a big script into Brave scriptlets will throw an error in settings.js

It breaks due to maximum stack exceeded error, as the code currently encodes utf8 string as uint8Array and then it is spread with ...chunks into String.fromCharCode, that will throw an error.

Issue in this line

String.fromCharCode(...chunk)

Solution should be something like this;

Image

Steps to reproduce

  1. Activate Brave scriptlets in Brave browser following official instructions
  2. While on brave://settings/shields/filters url, open the browser's developer tools to capture error.
  3. Add or edit the scriptlet that has 613229 chars (You can get one from here, as an example)
  4. Both adding or updating won't work, and in the console you will see the same error message.
Image
  1. Profit (Look at the console output for an error)

Actual result

Script is not saved.

Expected result

Script saves successfully

Reproduces how often

Easily reproduced

Brave version (brave://version info)

Brave 1.85.111 (Official Build) (arm64)
Chromium: 143.0.7499.40

Channel information

  • release (stable)
  • beta
  • nightly

Reproducibility

  • with Brave Shields disabled
  • with Brave Rewards disabled
  • in the latest version of Chrome

Miscellaneous information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions