Fixed international download filenames.
This commit is contained in:
parent
9592a2dd41
commit
7a34e8c169
|
@ -294,9 +294,9 @@ module.exports.CreateMeshDeviceFile = function (parent, ws, res, req, domain, us
|
|||
// Set the content disposition header for a HTTP response.
|
||||
// Because the filename can't have any special characters in it, we need to be extra careful.
|
||||
function setContentDispositionHeader(res, type, name, size, altname) {
|
||||
if (name != null) { name = require('path').basename(name).split('\\').join('').split('/').join('').split(':').join('').split('*').join('').split('?').join('').split('"').join('').split('<').join('').split('>').join('').split('|').join('').split(' ').join('').split('\'').join(''); } else { name = altname; }
|
||||
if (name != null) { name = require('path').basename(name).split('\\').join('').split('/').join('').split(':').join('').split('*').join('').split('?').join('').split('"').join('').split('<').join('').split('>').join('').split('|').join('').split('\'').join(''); } else { name = altname; }
|
||||
try {
|
||||
var x = { 'Cache-Control': 'no-store', 'Content-Type': type, 'Content-Disposition': 'attachment; filename="' + name + '"' };
|
||||
var x = { 'Cache-Control': 'no-store', 'Content-Type': type, 'Content-Disposition': 'attachment; filename*="' + encodeURIComponent(name) + '"; filename="' + altname + '"' };
|
||||
if (typeof size == 'number') { x['Content-Length'] = size; }
|
||||
res.set(x);
|
||||
} catch (ex) {
|
||||
|
|
|
@ -53,7 +53,7 @@ module.exports.CreateRedirServer = function (parent, db, args, func) {
|
|||
obj.app.get('/MeshServerRootCert.cer', function (req, res) {
|
||||
// The redirection server starts before certificates are loaded, make sure to handle the case where no certificate is loaded now.
|
||||
if (obj.certificates != null) {
|
||||
res.set({ 'Cache-Control': 'no-store', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename="' + obj.certificates.RootName + '.cer"' });
|
||||
res.set({ 'Cache-Control': 'no-store', 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename*="' + encodeURIComponent(obj.certificates.RootName) + '.cer"' });
|
||||
var rootcert = obj.certificates.root.cert;
|
||||
var i = rootcert.indexOf('-----BEGIN CERTIFICATE-----\r\n');
|
||||
if (i >= 0) { rootcert = rootcert.substring(i + 29); }
|
||||
|
|
|
@ -6705,9 +6705,9 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
|||
// Set the content disposition header for a HTTP response.
|
||||
// Because the filename can't have any special characters in it, we need to be extra careful.
|
||||
function setContentDispositionHeader(res, type, name, size, altname) {
|
||||
var name = require('path').basename(name).split('\\').join('').split('/').join('').split(':').join('').split('*').join('').split('?').join('').split('"').join('').split('<').join('').split('>').join('').split('|').join('').split(' ').join('').split('\'').join('');
|
||||
var name = require('path').basename(name).split('\\').join('').split('/').join('').split(':').join('').split('*').join('').split('?').join('').split('"').join('').split('<').join('').split('>').join('').split('|').join('').split('\'').join('');
|
||||
try {
|
||||
var x = { 'Cache-Control': 'no-store', 'Content-Type': type, 'Content-Disposition': 'attachment; filename="' + name + '"' };
|
||||
var x = { 'Cache-Control': 'no-store', 'Content-Type': type, 'Content-Disposition': 'attachment; filename*="' + encodeURIComponent(name) + '"; filename="' + altname + '"' };
|
||||
if (typeof size == 'number') { x['Content-Length'] = size; }
|
||||
res.set(x);
|
||||
} catch (ex) {
|
||||
|
|
Loading…
Reference in New Issue