From 7d6e15e465aa9a60fa4fb14cbfdeb024a18d22b8 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 6 Feb 2017 12:06:39 +0100 Subject: [PATCH] Throw an error when trying to open a document with the wrong app --- www/code/main.js | 6 ++++++ www/slide/main.js | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/www/code/main.js b/www/code/main.js index 13bd3d552..8595d3b2e 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -552,9 +552,15 @@ define([ var userDoc = module.realtime.getUserDoc(); + var newDoc = ""; if(userDoc !== "") { var hjson = JSON.parse(userDoc); + + if (typeof (hjson) !== 'object' || Array.isArray(hjson)) { + throw new Error("That realtime document is not compatible with the Code app"); + } + newDoc = hjson.content; if (hjson.highlightMode) { diff --git a/www/slide/main.js b/www/slide/main.js index cd69a64f9..5e8a9f41a 100644 --- a/www/slide/main.js +++ b/www/slide/main.js @@ -630,6 +630,10 @@ define([ var hjson = JSON.parse(userDoc); newDoc = hjson.content; + if (typeof (hjson) !== 'object' || Array.isArray(hjson)) { + throw new Error("That realtime document is not compatible with the Slide app"); + } + if (hjson.highlightMode) { setMode(hjson.highlightMode, module.$language); }