guard against a type error in user-object when FILES_DATA doesn't exist

pull/1/head
ansuz 3 years ago
parent a20bfbf6c1
commit 22357f882b

@ -316,13 +316,24 @@ define([
// Get data from AllFiles (Cryptpad_RECENTPADS) // Get data from AllFiles (Cryptpad_RECENTPADS)
var getFileData = exp.getFileData = function (file, editable) { var getFileData = exp.getFileData = function (file, editable) {
if (!file) { return; } if (!file) { return; }
var link = (files[STATIC_DATA] || {})[file]; var link;
try {
link = (files[STATIC_DATA] || {})[file];
} catch (err) {
console.error(err);
}
if (link) { if (link) {
var _link = editable ? link : Util.clone(link); var _link = editable ? link : Util.clone(link);
if (!editable) { _link.static = true; } if (!editable) { _link.static = true; }
return _link; return _link;
} }
var data = files[FILES_DATA][file] || {}; var data;
try {
data = files[FILES_DATA][file] || {};
} catch (err) {
console.error(err);
data = {};
}
if (!editable) { if (!editable) {
data = JSON.parse(JSON.stringify(data)); data = JSON.parse(JSON.stringify(data));
if (data.href && data.href.indexOf('#') === -1) { if (data.href && data.href.indexOf('#') === -1) {

Loading…
Cancel
Save