From 181a19a9a0d3f86f075fa4147c5d06173bf88e9c Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 29 Aug 2017 11:49:10 +0200 Subject: [PATCH] polyfill for array.fill --- www/common/boot2.js | 10 ++++++++++ www/common/cryptpad-common.js | 18 +++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/www/common/boot2.js b/www/common/boot2.js index 487eb8ae6..ec3b3d7db 100644 --- a/www/common/boot2.js +++ b/www/common/boot2.js @@ -11,6 +11,16 @@ define([ }; } + // file encryption/decryption won't work if you don't have Array.fill + if (typeof(Array.prototype.fill) !== 'function') { + Array.prototype.fill = function (x) { // CRYPTPAD_SHIM + var i = 0; + var l = this.length; + for (;i < l; i++) { this[i] = x; } + return this; + }; + } + var failStore = function () { console.error(new Error('wut')); require(['jquery'], function ($) { diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index ef55f6f6b..f5bbbef55 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -209,15 +209,18 @@ define([ common.isFeedbackAllowed = function () { try { - if (!getStore().getProxy().proxy.allowUserFeedback) { return; } + if (!getStore().getProxy().proxy.allowUserFeedback) { return false; } return true; - } catch (e) { return void console.error(e); } + } catch (e) { + console.error(e); + return false; + } }; var feedback = common.feedback = function (action, force) { + if (!action) { return; } if (force !== true) { - if (!action) { return; } try { - if (!getStore().getProxy().proxy.allowUserFeedback) { return; } + if (!common.isFeedbackAllowed()) { return; } } catch (e) { return void console.error(e); } } @@ -1951,10 +1954,15 @@ define([ feedback("NO_PROXIES"); } - if (/CRYPTPAD_SHIM/.test(Array.isArray.toString())) { + var shimPattern = /CRYPTPAD_SHIM/; + if (shimPattern.test(Array.isArray.toString())) { feedback("NO_ISARRAY"); } + if (shimPattern.test(Array.prototype.fill.toString())) { + feedback("NO_ARRAYFILL"); + } + common.reportScreenDimensions(); common.reportLanguage();