Skip to content
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

Injected global variable _global can clash with user code #645

Open
timfish opened this issue Jan 7, 2025 · 0 comments · May be fixed by #646
Open

Injected global variable _global can clash with user code #645

timfish opened this issue Jan 7, 2025 · 0 comments · May be fixed by #646
Assignees

Comments

@timfish
Copy link
Collaborator

timfish commented Jan 7, 2025

We inject code that creates a new variable called _global:

let code = `
var _global =
typeof window !== 'undefined' ?
window :
typeof global !== 'undefined' ?
global :
typeof globalThis !== 'undefined' ?
globalThis :
typeof self !== 'undefined' ?
self :
{};
_global.SENTRY_RELEASE={id:${JSON.stringify(release)}};`;

There is a chance this can clash with user code if that variable name is used.

We should either chose a variable name that is more unique and less likely to clash with user code or wrap this code block in a closure so that the scope is private.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant