Fixed improved content-disposition fix.
Ylian Saint-Hilaire committed
Apr 30, 2019 at 16:07 UTC
2041f9bba086bc1c9825872f613b36b3cf239af6
2 files changed
+8
-2
package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.3.3-m",
3
+ "version": "0.3.3-n",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",
webserver.js
+7
-1
@@ -2420,7 +2420,13 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2420
// Setup the response output
2421
var archive = require('archiver')('zip', { level: 5 }); // Sets the compression method.
2422
archive.on('error', function (err) { throw err; });
2423
- 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"' });
2423
+ try {
2424
+ // Set the agent download including the mesh name.
2425
+ 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"' });
2426
+ } catch (ex) {
2427
+ // If the mesh name contains invalid characters, just use a generic name.
2428
+ 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"' });
2429
+ }
2430
archive.pipe(res);
2431
2432
// Opens the "MeshAgentOSXPackager.zip"