From b419a6025f94f7e6262633ce1ff5b4c3e37e8483 Mon Sep 17 00:00:00 2001 From: Abhinav Adduri Date: Thu, 13 Jul 2017 12:53:15 -0700 Subject: [PATCH 1/5] fixes issues 195 and 192 --- frontend/src/download.js | 6 +++--- frontend/src/fileSender.js | 2 +- server/server.js | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frontend/src/download.js b/frontend/src/download.js index f16adf40..4100996a 100644 --- a/frontend/src/download.js +++ b/frontend/src/download.js @@ -65,7 +65,7 @@ $(document).ready(function() { return; }) .then(([decrypted, fname]) => { - name.innerText = fname; + name.innerText = decodeURIComponent(fname); const dataView = new DataView(decrypted); const blob = new Blob([dataView]); const downloadUrl = URL.createObjectURL(blob); @@ -74,10 +74,10 @@ $(document).ready(function() { a.href = downloadUrl; if (window.navigator.msSaveBlob) { // if we are in microsoft edge or IE - window.navigator.msSaveBlob(blob, fname); + window.navigator.msSaveBlob(blob, decodeURIComponent(fname)); return; } - a.download = fname; + a.download = decodeURIComponent(fname); document.body.appendChild(a); a.click(); }) diff --git a/frontend/src/fileSender.js b/frontend/src/fileSender.js index 888e1de4..0e1b32ba 100644 --- a/frontend/src/fileSender.js +++ b/frontend/src/fileSender.js @@ -131,7 +131,7 @@ class FileSender extends EventEmitter { JSON.stringify({ aad: arrayToHex(hash), id: fileId, - filename: file.name + filename: encodeURIComponent(file.name) }) ); xhr.send(fd); diff --git a/server/server.js b/server/server.js index e3c838a0..0508f092 100644 --- a/server/server.js +++ b/server/server.js @@ -94,7 +94,7 @@ app.get('/download/:id', (req, res) => { .length(id) .then(contentLength => { res.render('download', { - filename: filename, + filename: decodeURI(filename), filesize: bytes(contentLength), trackerId: conf.analytics_id, dsn: conf.sentry_id @@ -189,10 +189,10 @@ app.post('/upload', (req, res, next) => { } if ( - !validateIV(meta.id) || !meta.hasOwnProperty('aad') || !meta.hasOwnProperty('id') || - !meta.hasOwnProperty('filename') + !meta.hasOwnProperty('filename' || + !validateIV(meta.id)) ) { res.sendStatus(404); return; From 3f89c2bf0aeeb55358a185de924c497fda723ab4 Mon Sep 17 00:00:00 2001 From: Abhinav Adduri Date: Thu, 13 Jul 2017 12:55:34 -0700 Subject: [PATCH 2/5] changed to decodeURIComponent in server code --- server/server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/server.js b/server/server.js index 0508f092..294cb78a 100644 --- a/server/server.js +++ b/server/server.js @@ -94,7 +94,7 @@ app.get('/download/:id', (req, res) => { .length(id) .then(contentLength => { res.render('download', { - filename: decodeURI(filename), + filename: decodeURIComponent(filename), filesize: bytes(contentLength), trackerId: conf.analytics_id, dsn: conf.sentry_id From ef9b15c1d7130a2515f7116fae442e30c3f045e5 Mon Sep 17 00:00:00 2001 From: Abhinav Adduri Date: Thu, 13 Jul 2017 14:56:28 -0700 Subject: [PATCH 3/5] bracket typo --- server/server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/server.js b/server/server.js index 294cb78a..ed4ab692 100644 --- a/server/server.js +++ b/server/server.js @@ -191,8 +191,8 @@ app.post('/upload', (req, res, next) => { if ( !meta.hasOwnProperty('aad') || !meta.hasOwnProperty('id') || - !meta.hasOwnProperty('filename' || - !validateIV(meta.id)) + !meta.hasOwnProperty('filename') || + !validateIV(meta.id) ) { res.sendStatus(404); return; From c2e8139c6e816bd012352c894470e0a5f2c68352 Mon Sep 17 00:00:00 2001 From: Abhinav Adduri Date: Fri, 14 Jul 2017 08:59:59 -0700 Subject: [PATCH 4/5] moved decodeURIComponent to fileReceiver --- frontend/src/download.js | 6 +++--- frontend/src/fileReceiver.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/download.js b/frontend/src/download.js index 4100996a..f16adf40 100644 --- a/frontend/src/download.js +++ b/frontend/src/download.js @@ -65,7 +65,7 @@ $(document).ready(function() { return; }) .then(([decrypted, fname]) => { - name.innerText = decodeURIComponent(fname); + name.innerText = fname; const dataView = new DataView(decrypted); const blob = new Blob([dataView]); const downloadUrl = URL.createObjectURL(blob); @@ -74,10 +74,10 @@ $(document).ready(function() { a.href = downloadUrl; if (window.navigator.msSaveBlob) { // if we are in microsoft edge or IE - window.navigator.msSaveBlob(blob, decodeURIComponent(fname)); + window.navigator.msSaveBlob(blob, fname); return; } - a.download = decodeURIComponent(fname); + a.download = fname; document.body.appendChild(a); a.click(); }) diff --git a/frontend/src/fileReceiver.js b/frontend/src/fileReceiver.js index 17b5393f..41fb37d4 100644 --- a/frontend/src/fileReceiver.js +++ b/frontend/src/fileReceiver.js @@ -110,7 +110,7 @@ class FileReceiver extends EventEmitter { resolve(decrypted); }), new Promise((resolve, reject) => { - resolve(fname); + resolve(decodeURIComponent(fname)); }) ]); }); From 93d2e91afa831e3c2282f15ee869dec6afefea15 Mon Sep 17 00:00:00 2001 From: Abhinav Adduri Date: Mon, 17 Jul 2017 16:22:43 -0700 Subject: [PATCH 5/5] formatting --- frontend/src/download.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/download.js b/frontend/src/download.js index ab60e346..ae6fe65d 100644 --- a/frontend/src/download.js +++ b/frontend/src/download.js @@ -32,8 +32,8 @@ $(document).ready(function() { $('.percent-number').html(`${Math.floor(percent * 100)}`); if (progress[1] < 1000000) { $('.progress-text').html( - `${filename} (${(progress[0] / 1000).toFixed(1)}KB of ${(progress[1] / - 1000).toFixed(1)}KB)` + `${filename} (${(progress[0] / 1000).toFixed(1)}KB of + ${(progress[1] / 1000).toFixed(1)}KB)` ); } else if (progress[1] < 1000000000) { $('.progress-text').html(