From 01a3c13a8ca2a8b0327e17d78eb4270b246faa5b Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 12 Jun 2018 15:15:46 +0200 Subject: [PATCH] Fix CSP issues for missing files (404) --- customize.dist/translations/messages.fr.js | 2 +- customize.dist/translations/messages.js | 2 +- www/file/file-crypto.js | 1 + www/file/inner.js | 4 +++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 47dba647e..23fe16f91 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -618,7 +618,7 @@ define(function () { out.upload_mustLogin = "Vous devez vous connecter pour importer un fichier"; out.download_button = "Déchiffrer et télécharger"; out.download_mt_button = "Télécharger"; - out.download_resourceNotAvailable = "Le fichier demandé n'est pas disponible..."; + out.download_resourceNotAvailable = "Le fichier demandé n'est pas disponible... Appuyez sur Échap pour continuer."; out.todo_title = "CryptTodo"; out.todo_newTodoNamePlaceholder = "Décrivez votre tâche..."; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 7fe20b5d5..02ed5859c 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -622,7 +622,7 @@ define(function () { out.upload_mustLogin = "You must be logged in to upload files"; out.download_button = "Decrypt & Download"; out.download_mt_button = "Download"; - out.download_resourceNotAvailable = "The requested resource was not available..."; + out.download_resourceNotAvailable = "The requested resource was not available... Press Esc to continue."; out.todo_title = "CryptTodo"; out.todo_newTodoNamePlaceholder = "Describe your task..."; diff --git a/www/file/file-crypto.js b/www/file/file-crypto.js index 06f9804cd..1c274cbe7 100644 --- a/www/file/file-crypto.js +++ b/www/file/file-crypto.js @@ -65,6 +65,7 @@ define([ xhr.setRequestHeader('Range', 'bytes=0-1'); xhr.responseType = 'arraybuffer'; + xhr.onerror= function () { return CB('XHR_ERROR'); }; xhr.onload = function () { if (/^4/.test('' + this.status)) { return CB('XHR_ERROR'); } var res = new Uint8Array(xhr.response); diff --git a/www/file/inner.js b/www/file/inner.js index 1e2a4f3e1..e9e2d868d 100644 --- a/www/file/inner.js +++ b/www/file/inner.js @@ -95,7 +95,9 @@ define([ FileCrypto.fetchDecryptedMetadata(src, key, function (e, metadata) { if (e) { if (e === 'XHR_ERROR') { - return void UI.errorLoadingScreen(Messages.download_resourceNotAvailable); + return void UI.errorLoadingScreen(Messages.download_resourceNotAvailable, false, function () { + common.gotoURL('/file/'); + }); } return void console.error(e); }