fixes issues 195 and 192

This commit is contained in:
Abhinav Adduri 2017-07-13 12:53:15 -07:00
parent 52173bf6e7
commit b419a6025f
3 changed files with 7 additions and 7 deletions

View File

@ -65,7 +65,7 @@ $(document).ready(function() {
return; return;
}) })
.then(([decrypted, fname]) => { .then(([decrypted, fname]) => {
name.innerText = fname; name.innerText = decodeURIComponent(fname);
const dataView = new DataView(decrypted); const dataView = new DataView(decrypted);
const blob = new Blob([dataView]); const blob = new Blob([dataView]);
const downloadUrl = URL.createObjectURL(blob); const downloadUrl = URL.createObjectURL(blob);
@ -74,10 +74,10 @@ $(document).ready(function() {
a.href = downloadUrl; a.href = downloadUrl;
if (window.navigator.msSaveBlob) { if (window.navigator.msSaveBlob) {
// if we are in microsoft edge or IE // if we are in microsoft edge or IE
window.navigator.msSaveBlob(blob, fname); window.navigator.msSaveBlob(blob, decodeURIComponent(fname));
return; return;
} }
a.download = fname; a.download = decodeURIComponent(fname);
document.body.appendChild(a); document.body.appendChild(a);
a.click(); a.click();
}) })

View File

@ -131,7 +131,7 @@ class FileSender extends EventEmitter {
JSON.stringify({ JSON.stringify({
aad: arrayToHex(hash), aad: arrayToHex(hash),
id: fileId, id: fileId,
filename: file.name filename: encodeURIComponent(file.name)
}) })
); );
xhr.send(fd); xhr.send(fd);

View File

@ -94,7 +94,7 @@ app.get('/download/:id', (req, res) => {
.length(id) .length(id)
.then(contentLength => { .then(contentLength => {
res.render('download', { res.render('download', {
filename: filename, filename: decodeURI(filename),
filesize: bytes(contentLength), filesize: bytes(contentLength),
trackerId: conf.analytics_id, trackerId: conf.analytics_id,
dsn: conf.sentry_id dsn: conf.sentry_id
@ -189,10 +189,10 @@ app.post('/upload', (req, res, next) => {
} }
if ( if (
!validateIV(meta.id) ||
!meta.hasOwnProperty('aad') || !meta.hasOwnProperty('aad') ||
!meta.hasOwnProperty('id') || !meta.hasOwnProperty('id') ||
!meta.hasOwnProperty('filename') !meta.hasOwnProperty('filename' ||
!validateIV(meta.id))
) { ) {
res.sendStatus(404); res.sendStatus(404);
return; return;