From fc49715bc00d2226b97a4130f7fc35522901cb46 Mon Sep 17 00:00:00 2001 From: ansuz Date: Sat, 13 May 2017 12:32:26 +0200 Subject: [PATCH 1/4] document 'enableFeedback' in the server conf --- config.example.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/config.example.js b/config.example.js index 1be17e510..a91c384bd 100644 --- a/config.example.js +++ b/config.example.js @@ -211,6 +211,15 @@ module.exports = { */ restrictUploads: true, + /* clients can use the /settings/ app to opt out of usage feedback + * which informs the server of things like how much each app is being + * used, and whether certain clientside features are supported by + * the client's browser. The intent is to provide feedback to the admin + * such that the service can be improved. Enable this with `true` + * and ignore feedback with `false` or by commenting the attribute + */ + //logFeedback: true, + /* it is recommended that you serve cryptpad over https * the filepaths below are used to configure your certificates */ From 06f3d0eefe4473a5cabd33b23cdbb49f7dddc158 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 15 May 2017 10:26:52 +0200 Subject: [PATCH 2/4] shim isArray if not exists. correctly report how often this occurs --- www/common/boot2.js | 8 ++++++++ www/common/cryptpad-common.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/www/common/boot2.js b/www/common/boot2.js index 599875a93..d894191e8 100644 --- a/www/common/boot2.js +++ b/www/common/boot2.js @@ -10,5 +10,13 @@ define([], function () { "json.sortify": "/bower_components/json.sortify/dist/JSON.sortify" } }); + + // most of CryptPad breaks if you don't support isArray + if (!Array.isArray) { + Array.isArray = function(arg) { // CRYPTPAD_SHIM + return Object.prototype.toString.call(arg) === '[object Array]'; + }; + } + require([document.querySelector('script[data-bootload]').getAttribute('data-bootload')]); }); diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index f91069286..e6a48ebe2 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -1269,7 +1269,7 @@ define([ feedback("NO_PROXIES"); } - if (typeof(Array.isArray) !== 'function') { + if (!/CRYPTPAD_SHIM/.test(Array.isArray.toString())) { feedback("NO_ISARRAY"); } From 9bbd3161ca05c4a2a61425f5c98f04a5174c4d0b Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 15 May 2017 11:11:12 +0200 Subject: [PATCH 3/4] update tests for new API changes --- www/assert/main.js | 58 +++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/www/assert/main.js b/www/assert/main.js index 7da11f408..ffab3f5a9 100644 --- a/www/assert/main.js +++ b/www/assert/main.js @@ -153,50 +153,50 @@ define([ // check that old hashes parse correctly assert(function (cb) { - var secret = Cryptpad.parseHash('67b8385b07352be53e40746d2be6ccd7XAYSuJYYqa9NfmInyHci7LNy'); - return cb(secret.channel === "67b8385b07352be53e40746d2be6ccd7" && - secret.key === "XAYSuJYYqa9NfmInyHci7LNy" && - secret.version === 0); + var secret = Cryptpad.parsePadUrl('/pad/#67b8385b07352be53e40746d2be6ccd7XAYSuJYYqa9NfmInyHci7LNy'); + return cb(secret.hashData.channel === "67b8385b07352be53e40746d2be6ccd7" && + secret.hashData.key === "XAYSuJYYqa9NfmInyHci7LNy" && + secret.hashData.version === 0); }, "Old hash failed to parse"); // make sure version 1 hashes parse correctly assert(function (cb) { - var secret = Cryptpad.parseHash('/1/edit/3Ujt4F2Sjnjbis6CoYWpoQ/usn4+9CqVja8Q7RZOGTfRgqI'); - return cb(secret.version === 1 && - secret.mode === "edit" && - secret.channel === "3Ujt4F2Sjnjbis6CoYWpoQ" && - secret.key === "usn4+9CqVja8Q7RZOGTfRgqI" && - !secret.present); - }, "version 1 hash failed to parse"); + var secret = Cryptpad.parsePadUrl('/pad/#/1/edit/3Ujt4F2Sjnjbis6CoYWpoQ/usn4+9CqVja8Q7RZOGTfRgqI'); + return cb(secret.hashData.version === 1 && + secret.hashData.mode === "edit" && + secret.hashData.channel === "3Ujt4F2Sjnjbis6CoYWpoQ" && + secret.hashData.key === "usn4+9CqVja8Q7RZOGTfRgqI" && + !secret.hashData.present); + }, "version 1 hash (without present mode) failed to parse"); // test support for present mode in hashes assert(function (cb) { - var secret = Cryptpad.parseHash('/1/edit/CmN5+YJkrHFS3NSBg-P7Sg/DNZ2wcG683GscU4fyOyqA87G/present'); - return cb(secret.version === 1 - && secret.mode === "edit" - && secret.channel === "CmN5+YJkrHFS3NSBg-P7Sg" - && secret.key === "DNZ2wcG683GscU4fyOyqA87G" - && secret.present); + var secret = Cryptpad.parsePadUrl('/pad/#/1/edit/CmN5+YJkrHFS3NSBg-P7Sg/DNZ2wcG683GscU4fyOyqA87G/present'); + return cb(secret.hashData.version === 1 + && secret.hashData.mode === "edit" + && secret.hashData.channel === "CmN5+YJkrHFS3NSBg-P7Sg" + && secret.hashData.key === "DNZ2wcG683GscU4fyOyqA87G" + && secret.hashData.present); }, "version 1 hash failed to parse"); // test support for present mode in hashes assert(function (cb) { - var secret = Cryptpad.parseHash('/1/edit//CmN5+YJkrHFS3NSBg-P7Sg/DNZ2wcG683GscU4fyOyqA87G//present'); - return cb(secret.version === 1 - && secret.mode === "edit" - && secret.channel === "CmN5+YJkrHFS3NSBg-P7Sg" - && secret.key === "DNZ2wcG683GscU4fyOyqA87G" - && secret.present); + var secret = Cryptpad.parsePadUrl('/pad/#/1/edit//CmN5+YJkrHFS3NSBg-P7Sg/DNZ2wcG683GscU4fyOyqA87G//present'); + return cb(secret.hashData.version === 1 + && secret.hashData.mode === "edit" + && secret.hashData.channel === "CmN5+YJkrHFS3NSBg-P7Sg" + && secret.hashData.key === "DNZ2wcG683GscU4fyOyqA87G" + && secret.hashData.present); }, "Couldn't handle multiple successive slashes"); // test support for trailing slash assert(function (cb) { - var secret = Cryptpad.parseHash('/1/edit/3Ujt4F2Sjnjbis6CoYWpoQ/usn4+9CqVja8Q7RZOGTfRgqI/'); - return cb(secret.version === 1 && - secret.mode === "edit" && - secret.channel === "3Ujt4F2Sjnjbis6CoYWpoQ" && - secret.key === "usn4+9CqVja8Q7RZOGTfRgqI" && - !secret.present); + var secret = Cryptpad.parsePadUrl('/pad/#/1/edit/3Ujt4F2Sjnjbis6CoYWpoQ/usn4+9CqVja8Q7RZOGTfRgqI/'); + return cb(secret.hashData.version === 1 && + secret.hashData.mode === "edit" && + secret.hashData.channel === "3Ujt4F2Sjnjbis6CoYWpoQ" && + secret.hashData.key === "usn4+9CqVja8Q7RZOGTfRgqI" && + !secret.hashData.present); }, "test support for trailing slashes in version 1 hash failed to parse"); assert(function (cb) { From a9b670fdf55eff3177d3a4cfd761ca4cab1c71cf Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 15 May 2017 11:17:46 +0200 Subject: [PATCH 4/4] don't parse trailing slash as part of encryption key in old hashes --- www/common/common-hash.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/common-hash.js b/www/common/common-hash.js index 401291d6c..afb6bca2b 100644 --- a/www/common/common-hash.js +++ b/www/common/common-hash.js @@ -55,7 +55,7 @@ Version 1 if (hash.slice(0,1) !== '/' && hash.length >= 56) { // Old hash parsed.channel = hash.slice(0, 32); - parsed.key = hash.slice(32); + parsed.key = hash.slice(32, 56); parsed.version = 0; return parsed; }