Ability to open an anonymous read only shared folder
This commit is contained in:
@@ -1494,6 +1494,7 @@ define([
|
||||
noWorker = localStorage.CryptPad_noWorkers === '1';
|
||||
console.error('WebWorker/SharedWorker state forced to ' + !noWorker);
|
||||
}
|
||||
noWorker = true;
|
||||
Nthen(function (waitFor2) {
|
||||
if (Worker) {
|
||||
var w = waitFor2();
|
||||
|
||||
@@ -1154,9 +1154,12 @@ define([
|
||||
hide.push('openro'); // Remove open 'view' mode
|
||||
}
|
||||
// if it's not a plain text file
|
||||
var metadata = manager.getFileData(manager.find(path));
|
||||
if (!metadata || !Util.isPlainTextFile(metadata.fileType, metadata.title)) {
|
||||
hide.push('openincode');
|
||||
// XXX: there is a bug with this code in anon shared folder, so we disable it
|
||||
if (APP.loggedIn || !APP.newSharedFolder) {
|
||||
var metadata = manager.getFileData(manager.find(path));
|
||||
if (!metadata || !Util.isPlainTextFile(metadata.fileType, metadata.title)) {
|
||||
hide.push('openincode');
|
||||
}
|
||||
}
|
||||
} else if ($element.is('.cp-app-drive-element-sharedf')) {
|
||||
if (containsFolder) {
|
||||
|
||||
@@ -68,7 +68,7 @@ define([
|
||||
var listmapConfig = {
|
||||
data: {},
|
||||
channel: secret.channel,
|
||||
readOnly: false,
|
||||
readOnly: secret.keys && !secret.keys.editKeyStr,
|
||||
crypto: Crypto.createEncryptor(secret.keys),
|
||||
userName: 'sharedFolder',
|
||||
logLevel: 1,
|
||||
|
||||
@@ -687,6 +687,12 @@ define([
|
||||
href = el.href && ((el.href.indexOf('#') !== -1) ? el.href : exp.cryptor.decrypt(el.href));
|
||||
} catch (e) {}
|
||||
|
||||
if (href && href.indexOf('#') === -1) {
|
||||
// If we can't decrypt the href, it means we don't have the correct secondaryKey and we're in readOnly mode:
|
||||
// abort now, we won't be able to fix anything anyway
|
||||
continue;
|
||||
}
|
||||
|
||||
var parsed = Hash.parsePadUrl(href || el.roHref);
|
||||
var secret;
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ define([
|
||||
var data = {};
|
||||
userObjects.some(function (uo) {
|
||||
data = uo.getFileData(id, editable);
|
||||
if (Object.keys(data).length) { return true; }
|
||||
if (data && Object.keys(data).length) { return true; }
|
||||
});
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -114,10 +114,16 @@ define([
|
||||
|
||||
var getHref = exp.getHref = function (pad) {
|
||||
if (pad.href && pad.href.indexOf('#') !== -1) {
|
||||
// Href exists and is not encrypted: return href
|
||||
return pad.href;
|
||||
}
|
||||
if (pad.href) {
|
||||
return exp.cryptor.decrypt(pad.href);
|
||||
// Href exists and is encrypted
|
||||
var d = exp.cryptor.decrypt(pad.href);
|
||||
// If we can decrypt, return the decrypted value, otherwise continue and return roHref
|
||||
if (d.indexOf('#') !== -1) {
|
||||
return d;
|
||||
}
|
||||
}
|
||||
return pad.roHref;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user