From ed4438374bc34bb95076fb7425cde5060a4273e4 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 5 Jun 2025 18:51:44 +0200 Subject: [PATCH] Support non-crypto hashes in drive --- www/common/sframe-common-outer.js | 22 +++++++++++++++++++++- www/drive/main.js | 15 ++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 41eff191d..0ec64a964 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -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); } diff --git a/www/drive/main.js b/www/drive/main.js index e3155ab51..0028b2261 100644 --- a/www/drive/main.js +++ b/www/drive/main.js @@ -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; };