-
Notifications
You must be signed in to change notification settings - Fork 0
Remove eval #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Remove eval #21
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,6 +78,10 @@ export function stop(resetRecordingId: boolean) { | |
| if (resetRecordingId) { | ||
| removeRecordingId(); | ||
| } | ||
| const i = document.getElementById('rrwebcloud-recording-indicator'); | ||
| if (i) { | ||
| i.remove(); | ||
| } | ||
| } | ||
|
|
||
| function removeRecordingId(): void { | ||
|
|
@@ -291,6 +295,7 @@ export function start( | |
| recordVersion: __PKG_VERSION__, | ||
| recordCommitHash: __COMMIT_HASH__, | ||
| }; | ||
| initialPayload.jsSource = 'esm'; // this line get's replaced by prepublish-rrweb.sh | ||
|
|
||
| // the expected replacement of recording id | ||
| serverUrl = serverUrl.replace('{recordingId}', recordingId); | ||
|
|
@@ -482,11 +487,6 @@ if (document && document.currentScript) { | |
| .replace(/,(\s*[\]}])/g, '$1'), // allow trailing commas | ||
| ); | ||
| } catch (e) { | ||
| /* this allows bare prop names and single quoted values: | ||
| { | ||
| blockSelector: '.my-block-selector', | ||
| } | ||
| */ | ||
| config = looseJsonParse(self.innerText); | ||
| } | ||
| config = normalizeKeys(config, defaultClientConfig); | ||
|
|
@@ -522,10 +522,10 @@ if (document && document.currentScript) { | |
| } | ||
| } | ||
| function looseJsonParse(obj: string) { | ||
| // 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}`); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 The original code used Suggested fix: Either:
|
||
| return {} as recordOptions<eventWithTime> & clientConfig; | ||
| } | ||
|
|
||
| export default { | ||
| start, | ||
| stop, | ||
|
|
||
There was a problem hiding this comment.
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 usingelement.parentNode?.removeChild(element)for broader compatibility, or ensure this library only targets modern browsers.