From 7ae5654b8394d87fa376285e5eea6078ceca0ac4 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 27 Sep 2021 15:24:53 +0530 Subject: [PATCH 1/2] guard against type errors in contextual chat while in no-drive mode --- www/common/outer/messenger.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/common/outer/messenger.js b/www/common/outer/messenger.js index 981d9f8de..85400adc0 100644 --- a/www/common/outer/messenger.js +++ b/www/common/outer/messenger.js @@ -617,11 +617,11 @@ define([ return void cb({error: 'NO_SUCH_CHANNEL'}); } - var proxy = ctx.store.proxy; + var proxy = ctx.store.proxy || {}; var msg = [Types.message, proxy.curvePublic, +new Date(), payload]; if (!channel.isFriendChat) { var name = proxy[Constants.displayNameKey] || - Messages.anonymous + '#' + proxy.uid.slice(0,5); + Messages.anonymous + '#' + (proxy.uid || ctx.store.noDriveUid).slice(0,5); msg.push(name); } var msgStr = JSON.stringify(msg); From 04e298dd461b99328334dc94258111266fa7eaed Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 28 Sep 2021 15:44:21 +0200 Subject: [PATCH 2/2] Fix forms results with conditional sections (#799) --- www/form/export.js | 6 +++--- www/form/inner.js | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/www/form/export.js b/www/form/export.js index 4afc4170a..8983fd06c 100644 --- a/www/form/export.js +++ b/www/form/export.js @@ -13,14 +13,14 @@ define([ value += '"' + vv + '"'; return value; }; - Export.results = function (content, answers, TYPES) { + Export.results = function (content, answers, TYPES, order) { if (!content || !content.form) { return; } var csv = ""; var form = content.form; var questions = [Messages.form_poll_time, Messages.share_formView]; - content.order.forEach(function (key) { + order.forEach(function (key) { var obj = form[key]; if (!obj) { return; } var type = obj.type; @@ -44,7 +44,7 @@ define([ var user = msg._userdata || {}; csv += escapeCSV(time); csv += ',' + escapeCSV(user.name || Messages.anonymous); - content.order.forEach(function (key) { + order.forEach(function (key) { var type = form[key].type; if (!TYPES[type]) { return; } // Ignore static types if (TYPES[type].exportCSV) { diff --git a/www/form/inner.js b/www/form/inner.js index cb300facd..55d92f094 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -2628,7 +2628,7 @@ define([ var $results = $(results).appendTo($container); $(exportButton).click(function () { - var csv = Exporter.results(content, answers, TYPES); + var csv = Exporter.results(content, answers, TYPES, getFullOrder(content)); if (!csv) { return void UI.warn(Messages.error); } var suggestion = APP.framework._.title.suggestTitle('cryptpad-document'); var title = Util.fixFileName(suggestion) + '.csv'; @@ -2644,7 +2644,8 @@ define([ $controls.hide().append(switchMode); var show = function (answers, header) { - var elements = content.order.map(function (uid) { + var order = getFullOrder(content); + var elements = order.map(function (uid) { var block = form[uid]; var type = block.type; var model = TYPES[type];