From a0cf3eba40697238c5afea1b25ec4bf25f116f11 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 27 Apr 2021 14:51:11 +0200 Subject: [PATCH] Prevent parse errors in sframe-common-outer --- www/common/sframe-common-outer.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 7190fb997..d24f62f9d 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -44,8 +44,8 @@ define([ // loading screen setup. var done = waitFor(); var onMsg = function (msg) { - var data = JSON.parse(msg.data); - if (data.q !== 'READY') { return; } + var data = typeof(msg.data) === "string" ? JSON.parse(msg.data) : msg.data; + if (!data || data.q !== 'READY') { return; } window.removeEventListener('message', onMsg); var _done = done; done = function () { }; @@ -182,8 +182,8 @@ define([ }; var whenReady = waitFor(function (msg) { if (msg.source !== iframe) { return; } - var data = JSON.parse(msg.data); - if (!data.txid) { return; } + var data = typeof(msg.data) === "string" ? JSON.parse(msg.data) : msg.data; + if (!data || !data.txid) { return; } // Remove the listener once we've received the READY message window.removeEventListener('message', whenReady); // Answer with the requested data