From d674ac9e0c830551ae1057ee8fffc85e1b2f3f41 Mon Sep 17 00:00:00 2001 From: jonny Date: Sat, 1 May 2021 17:43:31 +0200 Subject: [PATCH 1/3] fixed url cannot be relative --- front/src/Api/IframeListener.ts | 8 ++++++-- front/src/Api/ScriptUtils.ts | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/front/src/Api/IframeListener.ts b/front/src/Api/IframeListener.ts index c875ebbb..3479a454 100644 --- a/front/src/Api/IframeListener.ts +++ b/front/src/Api/IframeListener.ts @@ -86,8 +86,12 @@ class IframeListener { else if(payload.type === 'goToPage' && isGoToPageEvent(payload.data)) { scriptUtils.goToPage(payload.data.url); } - else if(payload.type === 'openCoWebSite' && isOpenCoWebsite(payload.data)) { - scriptUtils.openCoWebsite(payload.data.url); + else if (payload.type === 'openCoWebSite' && isOpenCoWebsite(payload.data)) { + const scriptUrl = [...this.scripts.keys()].find(key => { + return this.scripts.get(key)?.contentWindow == message.source + }) + + scriptUtils.openCoWebsite(payload.data.url, scriptUrl || payload.data.url); } else if(payload.type === 'closeCoWebSite') { scriptUtils.closeCoWebSite(); diff --git a/front/src/Api/ScriptUtils.ts b/front/src/Api/ScriptUtils.ts index 1a7fed0f..8a5cb2c9 100644 --- a/front/src/Api/ScriptUtils.ts +++ b/front/src/Api/ScriptUtils.ts @@ -11,8 +11,7 @@ class ScriptUtils { } - public openCoWebsite(url : string){ - coWebsiteManager.loadCoWebsite(url,url); + public openCoWebsite(url: string, base: string) { } public closeCoWebSite(){ From 0a5dffd0344762d7a3f7e3f98cc097c97a86dd17 Mon Sep 17 00:00:00 2001 From: jonnytest1 Date: Mon, 3 May 2021 16:11:16 +0200 Subject: [PATCH 2/3] Update ScriptUtils.ts --- front/src/Api/ScriptUtils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/front/src/Api/ScriptUtils.ts b/front/src/Api/ScriptUtils.ts index 8a5cb2c9..e1c94507 100644 --- a/front/src/Api/ScriptUtils.ts +++ b/front/src/Api/ScriptUtils.ts @@ -12,6 +12,7 @@ class ScriptUtils { } public openCoWebsite(url: string, base: string) { + coWebsiteManager.loadCoWebsite(url, base); } public closeCoWebSite(){ From a24ca078e6534a93acfd0cd5d0e424a16db5766e Mon Sep 17 00:00:00 2001 From: jonny Date: Wed, 5 May 2021 19:11:48 +0200 Subject: [PATCH 3/3] use iframe url if no script # Conflicts: # front/src/Api/IframeListener.ts --- front/src/Api/IframeListener.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/front/src/Api/IframeListener.ts b/front/src/Api/IframeListener.ts index 3479a454..7e51a281 100644 --- a/front/src/Api/IframeListener.ts +++ b/front/src/Api/IframeListener.ts @@ -60,14 +60,14 @@ class IframeListener { // Do we trust the sender of this message? // Let's only accept messages from the iframe that are allowed. // Note: maybe we could restrict on the domain too for additional security (in case the iframe goes to another domain). - let found = false; + let foundSrc: string | null = null; for (const iframe of this.iframes) { if (iframe.contentWindow === message.source) { - found = true; + foundSrc = iframe.src; break; } } - if (!found) { + if (!foundSrc) { return; } @@ -91,7 +91,7 @@ class IframeListener { return this.scripts.get(key)?.contentWindow == message.source }) - scriptUtils.openCoWebsite(payload.data.url, scriptUrl || payload.data.url); + scriptUtils.openCoWebsite(payload.data.url, scriptUrl || foundSrc); } else if(payload.type === 'closeCoWebSite') { scriptUtils.closeCoWebSite();