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; } 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); 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');