Skip to content
Merged
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
31 changes: 31 additions & 0 deletions app/components/Views/BrowserTab/BrowserTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,23 @@ export const BrowserTab: React.FC<BrowserTabProps> = React.memo(
[handleError, handleSuccessfulPageResolution, favicon],
);

/**
* Check if any iFrame URLs are prohibited
*/
const checkIFrameUrls = useCallback(
async (iframeUrls: string[]) => {
for (const iframeUrl of iframeUrls) {
const { origin: iframeOrigin } = new URLParse(iframeUrl);
const isAllowed = await isAllowedOrigin(iframeOrigin);
if (!isAllowed) {
handleNotAllowedUrl(iframeOrigin);
return;
}
}
},
[isAllowedOrigin, handleNotAllowedUrl],
);

/**
* Handle message from website
*/
Expand All @@ -919,6 +936,20 @@ export const BrowserTab: React.FC<BrowserTabProps> = React.memo(
if (!dataParsed || (!dataParsed.type && !dataParsed.name)) {
return;
}
if (
dataParsed.type === 'IFRAME_DETECTED' &&
Array.isArray(dataParsed.iframeUrls) &&
dataParsed.iframeUrls.length > 0
) {
const validIframeUrls = dataParsed.iframeUrls.filter(
(url: unknown): url is string =>
typeof url === 'string' && url.trim().length > 0,
);
if (validIframeUrls.length > 0) {
checkIFrameUrls(validIframeUrls);
}
return;
}
if (dataParsed.name) {
backgroundBridgeRef.current?.onMessage(dataParsed);
return;
Expand Down
Loading