Support non-crypto hashes in drive

This commit is contained in:
yflory 2025-06-05 18:51:44 +02:00
parent f452ecd108
commit ed4438374b
2 changed files with 35 additions and 2 deletions

View File

@ -115,6 +115,7 @@ define([
var UnsafeIframe;
var OOIframe;
var Notifier;
var Ext;
var Utils = {
nThen: nThen
};
@ -152,6 +153,7 @@ define([
'/common/outer/local-store.js',
'/common/outer/login-block.js',
'/common/cache-store.js',
'/common/extensions.js',
'/customize/application_config.js',
//'/common/test.js',
'/common/user-object.js',
@ -160,7 +162,7 @@ define([
'/form/command-handler.js'
], waitFor(function (_CpNfOuter, _Cryptpad, _Crypto, _Cryptget, _SFrameChannel,
_SecureIframe, _UnsafeIframe, _OOIframe, _Notifier, _Hash, _Util, _Realtime, _Notify,
_Constants, _Feedback, _LocalStore, _Block, _Cache, _AppConfig, /* _Test,*/ _UserObject,
_Constants, _Feedback, _LocalStore, _Block, _Cache, _Ext, _AppConfig, /* _Test,*/ _UserObject,
_Instance, _PadTypes, _Handler) {
CpNfOuter = _CpNfOuter;
Cryptpad = _Cryptpad;
@ -171,6 +173,7 @@ define([
UnsafeIframe = _UnsafeIframe;
OOIframe = _OOIframe;
Notifier = _Notifier;
Ext = _Ext;
Utils.Hash = _Hash;
Utils.Util = _Util;
Utils.Realtime = _Realtime;
@ -757,6 +760,8 @@ define([
var isOO = ['sheet', 'doc', 'presentation'].indexOf(parsed.type) !== -1;
var ooDownloadData = {};
let hashInit = false;
var isDeleted = isNewFile && currentPad.hash.length > 0;
if (isDeleted) {
Utils.Cache.clearChannel(secret.channel);
@ -896,6 +901,21 @@ define([
cfg.addData(metaObj.priv, Cryptpad, metaObj.user, Utils);
}
if (edPrivate && !hashInit) {
Ext.getExtensionsSync('INIT_LOG').forEach(ext => {
if (!ext || !ext.getContent) { return; }
ext.getContent(sframeChan,
metaObj.priv, {
edPublic, edPrivate
}, (err, val) => {
if (hashInit) { return; }
hashInit = true;
});
//UI.log(ext.text);d
});
}
if (metaObj && metaObj.priv && typeof(metaObj.priv.plan) === "string") {
Utils.LocalStore.setPremium(metaObj.priv.plan);
}

View File

@ -101,7 +101,20 @@ define([
sframeChan.event('EV_DRIVE_REMOVE', data);
});
};
var addData = function (meta, Cryptpad) {
let safeHash;
if (hash) {
const hashStr = hash.slice(1);
if (!/^\//.test(hashStr)) {
window.location.hash = '';
safeHash = hashStr;
hash = '';
href = href.slice(0, href.indexOf('#'));
}
}
var addData = function (meta, Cryptpad, Utils) {
if (safeHash) { meta.safeHash = safeHash; }
if (!window.CryptPad_newSharedFolder) { return; }
meta.anonSFHref = Cryptpad.currentPad.href;
};