From 701d350fac7df86ae75ef079e162ae027dd6c0d0 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 23 Feb 2021 18:44:45 +0100 Subject: [PATCH 1/4] Fix shared folders access list --- www/common/outer/async-store.js | 3 +++ www/common/outer/sharedfolder.js | 17 ++++++++++++++--- www/common/outer/team.js | 1 + 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index 32cf421d5..56cba5ff6 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -67,6 +67,8 @@ define([ modules: {} }; + Store.onReadyEvt = onReadyEvt; + var getStore = function (teamId) { if (!teamId) { return store; } try { @@ -2242,6 +2244,7 @@ define([ isNew: isNew, network: store.network || store.networkPromise, store: s, + Store: Store, isNewChannel: Store.isNewChannel }, id, data, cb); }; diff --git a/www/common/outer/sharedfolder.js b/www/common/outer/sharedfolder.js index 7ae165e0b..35956b5ca 100644 --- a/www/common/outer/sharedfolder.js +++ b/www/common/outer/sharedfolder.js @@ -164,6 +164,16 @@ define([ readOnly: !Boolean(secondaryKey) }; + // If there is an allow list and we're offline, try again when we're synced + var onRejected = function (allowed, _cb) { + var cb = Util.once(Util.mkAsync(_cb)); + if (store.offline && config.Store) { + config.Store.onReadyEvt.reg(cb); + return; + } + cb('ERESTRICTED'); + }; + var owners = data.owners; var listmapConfig = { data: {}, @@ -179,7 +189,8 @@ define([ metadata: { validateKey: secret.keys.validateKey || undefined, owners: owners - } + }, + onRejected: onRejected }; var rt = sf.rt = Listmap.create(listmapConfig); rt.proxy.on('cacheready', function () { @@ -246,8 +257,6 @@ define([ return void cb(); } if (info.error === "ERESTRICTED" ) { - // This shouldn't happen: allow list are disabled for shared folders - // but call "cb" to make sure we won't block the initial "waitFor" sf.teams.forEach(function (obj) { obj.store.manager.restrictedProxy(obj.id, secret.channel); }); @@ -326,6 +335,7 @@ define([ network: network, store: s, updatePassword: true, + Store: Store, isNewChannel: Store.isNewChannel }, sfId, sf, waitFor()); if (!s.rpc) { return; } @@ -356,6 +366,7 @@ define([ SF.load({ network: network, store: store, + Store: Store, isNewChannel: Store.isNewChannel }, id, sf, waitFor(function () { progress({ diff --git a/www/common/outer/team.js b/www/common/outer/team.js index 70d5acfcd..2efc574af 100644 --- a/www/common/outer/team.js +++ b/www/common/outer/team.js @@ -280,6 +280,7 @@ define([ isNew: isNew, network: ctx.store.network, store: team, + Store: ctx.Store, isNewChannel: ctx.Store.isNewChannel }, id, data, cb); }; From dc6446b0881f4f5295fa103fecb3402441899a0e Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 24 Feb 2021 09:12:39 +0530 Subject: [PATCH 2/4] use markdown block styles for plaintext in the file app --- www/file/app-file.less | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/file/app-file.less b/www/file/app-file.less index 739720f6e..cfbf0afa3 100644 --- a/www/file/app-file.less +++ b/www/file/app-file.less @@ -58,8 +58,8 @@ width: 90vw; height: 100%; padding: 2em; - background-color: @cp_mediatag-text-bg; - color: @cp_mediatag-text-fg; + background-color: @cp_markdown-block-bg; + color: @cp_markdown-block-fg; overflow-y: auto; word-wrap: break-word; white-space: pre-wrap; From 436f1d55c92e171ae9dadbe617a5ac3241a28e7a Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 24 Feb 2021 09:32:46 +0530 Subject: [PATCH 3/4] update changelog after latest review --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1bc84a52..310f66254 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,10 @@ * refactor /assert/ * introduce /checkup/ page for detecting incorrect instance configuration * fix tippy popper color +* loss of access to shared folders + * related to access lists and the offline cache +* remove old and unused translations +* fix plaintext colors in file app # 4.1.0 (B) From c84ecbabc0ccecf58af010724d5599686dfd28bd Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 24 Feb 2021 13:53:59 +0530 Subject: [PATCH 4/4] more tests for the checkup page --- .../src/less2/pages/page-checkup.less | 57 ++++++++++++ www/checkup/index.html | 20 ---- www/checkup/main.js | 92 ++++++++++++++----- 3 files changed, 128 insertions(+), 41 deletions(-) create mode 100644 customize.dist/src/less2/pages/page-checkup.less diff --git a/customize.dist/src/less2/pages/page-checkup.less b/customize.dist/src/less2/pages/page-checkup.less new file mode 100644 index 000000000..a4ece61a4 --- /dev/null +++ b/customize.dist/src/less2/pages/page-checkup.less @@ -0,0 +1,57 @@ +@import (reference) "../include/colortheme-all.less"; +@import (reference) "../include/font.less"; +//@import (reference) "../include/forms.less"; +@import (reference) "../include/alertify.less"; + +html, body { + .font_main(); + .alertify_main(); + height: 100%; + margin: 0px; + padding: 0px; + background-color: @cp_static-bg !important; + color: @cryptpad_text_col; + font-family: "IBM Plex Mono"; + + .report { + font-size: 30px; + max-width: 50%; + margin: auto; + padding-top: 15px; + } + + .success { + border: 1px solid green; + } + .failure { + border: 1px solid red; + } + .error { + border: 1px solid red; + } + .hidden { + display: none; + } + + .failures div.error, .summary { + padding: 15px; + } + + table { + td { + padding: 5px; + border: 1px solid white; + } + } + + .advisory-text { + display: inline-block; + word-break: break-all; + padding: 5px; + //font-size: 16px; + border: 1px solid red; + background-color: @cp_alerts-danger-bg; + color: @cp_alerts-danger-text; + } +} + diff --git a/www/checkup/index.html b/www/checkup/index.html index 2309ffd56..afa469f7f 100644 --- a/www/checkup/index.html +++ b/www/checkup/index.html @@ -4,26 +4,6 @@ - - - diff --git a/www/checkup/main.js b/www/checkup/main.js index 9097894fc..92f131548 100644 --- a/www/checkup/main.js +++ b/www/checkup/main.js @@ -4,25 +4,74 @@ define([ '/assert/assertions.js', '/common/hyperscript.js', '/customize/messages.js', + '/common/sframe-common-outer.js', + '/bower_components/tweetnacl/nacl-fast.min.js', - 'less!/customize/src/less2/pages/page-assert.less', -], function ($, ApiConfig, Assertions, h, Messages) { + 'less!/customize/src/less2/pages/page-checkup.less', +], function ($, ApiConfig, Assertions, h, Messages, SFCommonO) { var assert = Assertions(); + var trimSlashes = function (s) { + if (typeof(s) !== 'string') { return s; } + return s.replace(/\/+$/, ''); + }; + + var _alert = function (content) { + return h('span.advisory-text', content); + }; + + var trimmedSafe = trimSlashes(ApiConfig.httpSafeOrigin); + var trimmedUnsafe = trimSlashes(ApiConfig.httpUnsafeOrigin); + assert(function (cb) { - var c = ApiConfig; - cb(Boolean(c.httpUnsafeOrigin && c.httpSafeOrigin)); - }, "Sandbox configuration: ensure that both httpUnsafeOrigin and httpSafeOrigin are defined"); // XXX + //console.error(trimmedSafe, trimmedUnsafe); + cb(Boolean(trimmedSafe && trimmedUnsafe)); + }, _alert("Sandbox configuration: ensure that both httpUnsafeOrigin and httpSafeOrigin are defined")); assert(function (cb) { - var c = ApiConfig; - return void cb(c.httpUnsafeOrigin !== c.httpSafeOrigin); - }, 'Sandbox configuration: httpUnsafeOrigin !== httpSafeOrigin'); // XXX + return void cb(trimmedSafe !== trimmedUnsafe); + }, _alert('Sandbox configuration: httpUnsafeOrigin !== httpSafeOrigin')); assert(function (cb) { cb((window.location.origin + '/') === ApiConfig.httpUnsafeOrigin); - }, 'Sandbox configuration: loading via httpUnsafeOrigin'); // XXX + }, _alert('Sandbox configuration: loading via httpUnsafeOrigin')); + + + var checkAvailability = function (url, cb) { + $.ajax({ + url: url, + date: {}, + complete: function (xhr) { + cb(xhr.status === 200); + }, + }); + }; + + assert(function (cb) { + checkAvailability(trimmedUnsafe, cb); + }, _alert("Main domain is not available")); + + assert(function (cb) { + console.log(trimmedSafe); + checkAvailability(trimmedSafe, cb); + }, _alert("Sandbox domain is not available")); // XXX Blocked by CSP. try loading it via sframe ? + + var row = function (cells) { + return h('tr', cells.map(function (cell) { + return h('td', cell); + })); + }; + + var failureReport = function (obj) { + return h('div.error', [ + h('h5', obj.message), + h('table', [ + row(["Failed test number", obj.test + 1]), + row(["Returned value", obj.output]), + ]), + ]); + }; assert.run(function (state) { var errors = state.errors; @@ -31,19 +80,20 @@ define([ Messages.assert_numberOfTestsPassed = "{0} / {1} tests passed."; var statusClass = failed? 'failure': 'success'; - $('body').prepend(h('div.report.' + statusClass, [ - Messages._getKey('assert_numberOfTestsPassed', [ + + var summary = h('div.summary.' + statusClass, [ + h('p', Messages._getKey('assert_numberOfTestsPassed', [ state.passed, state.total - ]), - h('div.failures', errors.map(function (obj) { - return h('p.error', [ - h('p', "Test number: " + obj.test), - h('p', "Error message: " + obj.message), - h('p', "Returned value: " + obj.output), - h('br'), - ]); - })), - ])); + ])), + h('p', "Details found below"), + ]); + + var report = h('div.report', [ + summary, + h('div.failures', errors.map(failureReport)), + ]); + + $('body').prepend(report); }); });