Skip to content

Remove eval#21

Open
eoghanmurray wants to merge 2 commits intomasterfrom
remove-eval
Open

Remove eval#21
eoghanmurray wants to merge 2 commits intomasterfrom
remove-eval

Conversation

@eoghanmurray
Copy link
Copy Markdown
Collaborator

Take out the eval as it will cause problems when publishing or importing depending on the environment

Leave a placeholder function for looseParseJSON which can be post processed to run something like https://github.com/ssnau/loose-json (or the previous code included here)

Also incidentally add some 'stop' code to remove an rrwebcloud bookmarklet indicator if present

…rs in https://rrwebcloud.com/record.js - we don't want it in the bookmarklet (config already well formed) or in the NPM package
… e.g. for the bookmarklet we will inject some indicator code here
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 13, 2026

⚠️ No Changeset found

Latest commit: b74c2fb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#never_use_direct_eval!
return eval?.(`"use strict";(${obj})`);
// this is replaced by an eval in prepublish-rrweb.sh
console.log(`couldn't parse config as JSON: ${obj}`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL: Config parsing is completely broken - this function now always returns an empty object {} instead of parsing the config. When JSON.parse fails (line 484-490), it falls back to looseJsonParse which returns {}, meaning users' custom configurations will be lost.

The original code used eval to parse JavaScript-style config objects (e.g., {blockSelector: '.my-block-selector'}). While removing eval is good for security, this replacement doesn't actually parse anything - it just silently fails.

Suggested fix: Either:

  1. Actually implement JSON5 parsing (there are libraries like json5 npm package)
  2. Or keep a safe eval alternative that doesn't use direct eval (e.g., using Function constructor with limited scope)

}
const i = document.getElementById('rrwebcloud-recording-indicator');
if (i) {
i.remove();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Element.remove() method is not supported in IE or older browsers. Consider using element.parentNode?.removeChild(element) for broader compatibility, or ensure this library only targets modern browsers.

@kilo-code-bot
Copy link
Copy Markdown

kilo-code-bot Bot commented Mar 13, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 1
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

CRITICAL

File Line Issue
packages/ws-client/src/index.ts 526 Config parsing is completely broken - always returns empty object {} instead of parsing user config

WARNING

File Line Issue
packages/ws-client/src/index.ts 83 Element.remove() not supported in older browsers (IE)
Files Reviewed (1 file)
  • packages/ws-client/src/index.ts - 2 issues

Review generated by Kilo Code Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant