mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-13 18:45:43 +05:00
Fix encrypted edit links when downloading shared folders
This commit is contained in:
parent
53c647f7ca
commit
ec39425791
@ -10,12 +10,13 @@ define([
|
||||
'/common/common-interface.js',
|
||||
'/common/hyperscript.js',
|
||||
'/common/common-feedback.js',
|
||||
'/common/userObject.js',
|
||||
'/common/inner/cache.js',
|
||||
'/customize/messages.js',
|
||||
'/components/nthen/index.js',
|
||||
'/components/saferphore/index.js',
|
||||
'/components/jszip/dist/jszip.min.js',
|
||||
], function ($, FileCrypto, Hash, Util, UI, h, Feedback,
|
||||
], function ($, FileCrypto, Hash, Util, UI, h, Feedback, UO,
|
||||
Cache, Messages, nThen, Saferphore, JsZip) {
|
||||
var saveAs = window.saveAs;
|
||||
|
||||
@ -170,7 +171,7 @@ define([
|
||||
});
|
||||
}
|
||||
|
||||
var href = (fData.href && fData.href.indexOf('#') !== -1) ? fData.href : fData.roHref;
|
||||
let href = UO.getHref(fData, ctx.currentCryptor);
|
||||
var parsed = Hash.parsePadUrl(href);
|
||||
if (['pad', 'file'].indexOf(parsed.hashData.type) === -1) { return; }
|
||||
|
||||
@ -294,9 +295,17 @@ define([
|
||||
if (typeof el === "object" && el.metadata !== true) { // if folder
|
||||
var fName = getUnique(sanitize(k), '', existingNames);
|
||||
existingNames.push(fName.toLowerCase());
|
||||
ctx.currentCryptor = undefined;
|
||||
return void makeFolder(ctx, el, zip.folder(fName), fd);
|
||||
}
|
||||
if (ctx.data.sharedFolders[el]) { // if shared folder
|
||||
let obj = ctx.data.sharedFolders[el];
|
||||
let parsed = Hash.parsePadUrl(obj.href || obj.roHref);
|
||||
var secret = Hash.getSecrets('drive', parsed.hash, obj.password);
|
||||
let cryptor = secret.keys?.secondaryKey ? UO.createCryptor(secret.keys?.secondaryKey)
|
||||
: undefined;
|
||||
ctx.currentCryptor = cryptor;
|
||||
|
||||
var sfData = ctx.sf[el].metadata;
|
||||
var sfName = getUnique(sanitize((sfData && sfData.title) || 'Folder'), '', existingNames);
|
||||
existingNames.push(sfName.toLowerCase());
|
||||
|
||||
@ -72,7 +72,7 @@ define([
|
||||
// Href exists and is not encrypted: return href
|
||||
return pad.href;
|
||||
}
|
||||
if (pad.href) {
|
||||
if (pad.href && cryptor) {
|
||||
// Href exists and is encrypted
|
||||
var d = cryptor.decrypt(pad.href);
|
||||
// If we can decrypt, return the decrypted value, otherwise continue and return roHref
|
||||
|
||||
Loading…
Reference in New Issue
Block a user