From e5abaa34b229c538d2d4b7a5202981068a1468c7 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 29 Jan 2019 11:40:44 +0100 Subject: [PATCH 1/3] Fix cursor channel not updated to ephemeral --- www/common/sframe-common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js index 1236d4fcd..d6cbfc350 100644 --- a/www/common/sframe-common.js +++ b/www/common/sframe-common.js @@ -201,7 +201,7 @@ define([ if (typeof(channel) !== 'string' || channel.length !== Hash.ephemeralChannelLength) { channel = Hash.createChannelId(true); // true indicates that it's an ephemeral channel } - if (!md.cursor) { + if (md.cursor !== channel) { md.cursor = channel; ctx.metadataMgr.updateMetadata(md); setTimeout(saveChanges); From 5175ed10c5446e67c437920cb5753833fcba377e Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 29 Jan 2019 11:56:55 +0100 Subject: [PATCH 2/3] update example nginx config for spreadsheets --- docs/example.nginx.conf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/example.nginx.conf b/docs/example.nginx.conf index 5c4ff2fbe..9d856a5a9 100644 --- a/docs/example.nginx.conf +++ b/docs/example.nginx.conf @@ -46,6 +46,8 @@ server { set $unsafe 0; if ($uri = "/pad/inner.html") { set $unsafe 1; } + if ($uri = "/sheet/inner.html") { set $unsafe 1; } + if ($uri = "/common/onlyoffice/web-apps/apps/spreadsheeteditor/main/index.html") { set $unsafe 1; } if ($host != sandbox.cryptpad.info) { set $unsafe 0; } if ($unsafe) { set $scriptSrc "'self' 'unsafe-eval' 'unsafe-inline' new2.cryptpad.fr cryptpad.fr"; @@ -95,7 +97,7 @@ server { try_files $uri =404; } - location ~ ^/(register|login|settings|user|pad|drive|poll|slide|code|whiteboard|file|media|profile|contacts|todo|filepicker|debug|kanban)$ { + location ~ ^/(register|login|settings|user|pad|drive|poll|slide|code|whiteboard|file|media|profile|contacts|todo|filepicker|debug|kanban|sheet)$ { rewrite ^(.*)$ $1/ redirect; } From bd6a9ed3f8d6ff42d5425da2795496bdbe3fc9ea Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 31 Jan 2019 11:57:16 +0100 Subject: [PATCH 3/3] Use the correct API for the filepicker channel --- www/filepicker/main.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/www/filepicker/main.js b/www/filepicker/main.js index 596cc0a45..5792001e5 100644 --- a/www/filepicker/main.js +++ b/www/filepicker/main.js @@ -41,10 +41,34 @@ define([ var Utils = config.modules.Utils; nThen(function (waitFor) { - config.modules.SFrameChannel.create($('#sbox-filePicker-iframe')[0].contentWindow, - waitFor(function (sfc) { + // The inner iframe tries to get some data from us every ms (cache, store...). + // It will send a "READY" message and wait for our answer with the correct txid. + // First, we have to answer to this message, otherwise we're going to block + // sframe-boot.js. Then we can start the channel. + var msgEv = Utils.Util.mkEvent(); + var iframe = $('#sbox-filePicker-iframe')[0].contentWindow; + var postMsg = function (data) { + iframe.postMessage(data, '*'); + }; + var whenReady = waitFor(function (msg) { + if (msg.source !== iframe) { return; } + var data = JSON.parse(msg.data); + if (!data.txid) { return; } + // Remove the listener once we've received the READY message + window.removeEventListener('message', whenReady); + // Answer with the requested data + postMsg(JSON.stringify({ txid: data.txid, language: Cryptpad.getLanguage() })); + + // Then start the channel + window.addEventListener('message', function (msg) { + if (msg.source !== iframe) { return; } + msgEv.fire(msg); + }); + config.modules.SFrameChannel.create(msgEv, postMsg, waitFor(function (sfc) { sframeChan = sfc; })); + }); + window.addEventListener('message', whenReady); }).nThen(function () { var updateMeta = function () { //console.log('EV_METADATA_UPDATE');