From 2041f9bba086bc1c9825872f613b36b3cf239af6 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Tue, 30 Apr 2019 16:07:14 -0700 Subject: [PATCH] Fixed improved content-disposition fix. --- package.json | 2 +- webserver.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e49336a3..67b035ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.3.3-m", + "version": "0.3.3-n", "keywords": [ "Remote Management", "Intel AMT", diff --git a/webserver.js b/webserver.js index f39f885f..9cb3c9a4 100644 --- a/webserver.js +++ b/webserver.js @@ -2420,7 +2420,13 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { // Setup the response output var archive = require('archiver')('zip', { level: 5 }); // Sets the compression method. archive.on('error', function (err) { throw err; }); - res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/zip', 'Content-Disposition': 'attachment; filename="MeshAgent-' + mesh.name + '.zip"' }); + try { + // Set the agent download including the mesh name. + res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/zip', 'Content-Disposition': 'attachment; filename="MeshAgent-' + mesh.name + '.zip"' }); + } catch (ex) { + // If the mesh name contains invalid characters, just use a generic name. + res.set({ 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'Content-Type': 'application/zip', 'Content-Disposition': 'attachment; filename="MeshAgent.zip"' }); + } archive.pipe(res); // Opens the "MeshAgentOSXPackager.zip"