diff --git a/server.js b/server.js index a3429f3df..63f5738a2 100644 --- a/server.js +++ b/server.js @@ -105,6 +105,18 @@ app.head(/^\/common\/feedback\.html/, function (req, res, next) { }()); app.use(function (req, res, next) { + if (req.method === 'OPTIONS' && /\/blob\//.test(req.url)) { + console.log(req.url); + res.setHeader('Access-Control-Allow-Origin', '*'); + res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS'); + res.setHeader('Access-Control-Allow-Headers', 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range'); + res.setHeader('Access-Control-Max-Age', 1728000); + res.setHeader('Content-Type', 'application/octet-stream; charset=utf-8'); + res.setHeader('Content-Length', 0); + res.statusCode = 204; + return void res.end(); + } + setHeaders(req, res); if (/[\?\&]ver=[^\/]+$/.test(req.url)) { res.setHeader("Cache-Control", "max-age=31536000"); } next(); diff --git a/www/common/make-backup.js b/www/common/make-backup.js index cb6f5bf2b..50a62456d 100644 --- a/www/common/make-backup.js +++ b/www/common/make-backup.js @@ -55,7 +55,7 @@ define([ var hash = parsed.hash; var name = fData.filename || fData.title; var secret = Hash.getSecrets('file', hash, fData.password); - var src = Hash.getBlobPathFromHex(secret.channel); + var src = (ctx.fileHost || '') + Hash.getBlobPathFromHex(secret.channel); var key = secret.keys && secret.keys.cryptKey; Util.fetch(src, function (err, u8) { if (cancelled) { return; } @@ -266,10 +266,11 @@ define([ }; // Main function. Create the empty zip and fill it starting from drive.root - var create = function (data, getPad, cb, progress) { + var create = function (data, getPad, fileHost, cb, progress) { if (!data || !data.uo || !data.uo.drive) { return void cb('EEMPTY'); } var sem = Saferphore.create(5); var ctx = { + fileHost: fileHost, get: getPad, data: data.uo.drive, folder: data.folder || ctx.data.root, diff --git a/www/common/sframe-common-file.js b/www/common/sframe-common-file.js index d79ed758d..fc30f8831 100644 --- a/www/common/sframe-common-file.js +++ b/www/common/sframe-common-file.js @@ -595,7 +595,9 @@ define([ }); }; + var privateData = common.getMetadataMgr().getPrivateData(); var ctx = { + fileHost: privateData.fileHost, get: common.getPad, sframeChan: sframeChan, }; diff --git a/www/common/translations/messages.fr.json b/www/common/translations/messages.fr.json index 76116bb6d..1fb078376 100644 --- a/www/common/translations/messages.fr.json +++ b/www/common/translations/messages.fr.json @@ -1116,7 +1116,7 @@ "support_notification": "Un administrateur a répondu à votre ticket de support", "requestEdit_button": "Demander les droits d'édition", "requestEdit_dialog": "Êtes-vous sûr de vouloir demander les droits d'édition de ce pad au propriétaire ?", - "requestEdit_confirm": "{1} a demandé les droits d'édition pour le pad {1}. Souhaitez-vous leur accorder les droits ?", + "requestEdit_confirm": "{1} a demandé les droits d'édition pour le pad {0}. Souhaitez-vous leur accorder les droits ?", "requestEdit_fromFriend": "Vous êtes amis avec {0}", "requestEdit_fromStranger": "Vous n'êtes pas amis avec {0}", "requestEdit_viewPad": "Ouvrir le pad dans un nouvel onglet", diff --git a/www/file/inner.js b/www/file/inner.js index 6a78e5f45..1cbe3e8c3 100644 --- a/www/file/inner.js +++ b/www/file/inner.js @@ -59,7 +59,7 @@ define([ var secret; var metadataMgr = common.getMetadataMgr(); var priv = metadataMgr.getPrivateData(); - var fileHost = priv.fileHost || priv.origin; + var fileHost = priv.fileHost || priv.origin || ''; if (!priv.filehash) { uploadMode = true; diff --git a/www/settings/inner.js b/www/settings/inner.js index f92df0221..22ad7cc49 100644 --- a/www/settings/inner.js +++ b/www/settings/inner.js @@ -1085,7 +1085,7 @@ define([ var todo = function (data, filename) { var ui = createExportUI(); - var bu = Backup.create(data, common.getPad, function (blob, errors) { + var bu = Backup.create(data, common.getPad, privateData.fileHost, function (blob, errors) { saveAs(blob, filename); sframeChan.event('EV_CRYPTGET_DISCONNECT'); ui.complete(function () {