From 22357f882b3f4e425277e95e92343901819a49c8 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 3 Aug 2021 12:17:42 +0530 Subject: [PATCH] guard against a type error in user-object when FILES_DATA doesn't exist --- www/common/userObject.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/www/common/userObject.js b/www/common/userObject.js index 9de3ea918..c3960ebfd 100644 --- a/www/common/userObject.js +++ b/www/common/userObject.js @@ -316,13 +316,24 @@ define([ // Get data from AllFiles (Cryptpad_RECENTPADS) var getFileData = exp.getFileData = function (file, editable) { if (!file) { return; } - var link = (files[STATIC_DATA] || {})[file]; + var link; + try { + link = (files[STATIC_DATA] || {})[file]; + } catch (err) { + console.error(err); + } if (link) { var _link = editable ? link : Util.clone(link); if (!editable) { _link.static = true; } return _link; } - var data = files[FILES_DATA][file] || {}; + var data; + try { + data = files[FILES_DATA][file] || {}; + } catch (err) { + console.error(err); + data = {}; + } if (!editable) { data = JSON.parse(JSON.stringify(data)); if (data.href && data.href.indexOf('#') === -1) {