Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,26 @@
return defaultObj.prototype as BasePrototypeCache[T];
}

let iframeEl: HTMLIFrameElement | undefined;
try {
const iframeEl = document.createElement('iframe');
iframeEl = document.createElement('iframe');
document.body.appendChild(iframeEl);
const win = iframeEl.contentWindow;
if (!win) return defaultObj.prototype as BasePrototypeCache[T];

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
const untaintedObject = (win as any)[key]
.prototype as BasePrototypeCache[T];
// cleanup
document.body.removeChild(iframeEl);

if (!untaintedObject) return defaultPrototype;

return (untaintedBasePrototype[key] = untaintedObject);
} catch {
return defaultPrototype;
} finally {
if (iframeEl?.parentNode) {
iframeEl.parentNode.removeChild(iframeEl);
}
}
}

Expand Down Expand Up @@ -224,7 +227,7 @@

// copy from https://github.com/getsentry/sentry-javascript/blob/b2109071975af8bf0316d3b5b38f519bdaf5dc15/packages/utils/src/object.ts
export function patch(
source: { [key: string]: any },

Check warning on line 230 in packages/utils/src/index.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/utils/src/index.ts#L230

[@typescript-eslint/no-explicit-any] Unexpected any. Specify a different type.
name: string,
replacement: (...args: unknown[]) => unknown,
): () => void {
Expand Down
Loading