From dabd80a82fe99560deff6978cb48bd8492652db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9opold=20Jacquot?= Date: Mon, 24 Feb 2020 14:20:48 +0100 Subject: [PATCH] Fix content-disposition header with filename containing special char --- Common/sources/storage-s3.js | 2 +- Common/sources/utils.js | 17 ----------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/Common/sources/storage-s3.js b/Common/sources/storage-s3.js index af445830..dfaf73f4 100644 --- a/Common/sources/storage-s3.js +++ b/Common/sources/storage-s3.js @@ -205,7 +205,7 @@ exports.getSignedUrl = function(baseUrl, strPath, urlType, optFilename, opt_type return new Promise(function(resolve, reject) { var expires = (commonDefines.c_oAscUrlTypes.Session === urlType ? cfgExpSessionAbsolute : cfgStorageUrlExpires) || 31536000; var userFriendlyName = optFilename ? optFilename.replace(/\//g, "%2f") : path.basename(strPath); - var contentDisposition = utils.getContentDispositionS3(userFriendlyName, null, opt_type); + var contentDisposition = utils.getContentDisposition(userFriendlyName, null, opt_type); if (cfgUseRequestToGetUrl) { //default Expires 900 seconds var params = { diff --git a/Common/sources/utils.js b/Common/sources/utils.js index feacc2ab..6ad9c0ce 100644 --- a/Common/sources/utils.js +++ b/Common/sources/utils.js @@ -233,24 +233,7 @@ function getContentDisposition (opt_filename, opt_useragent, opt_type) { } return contentDisposition; } -function getContentDispositionS3 (opt_filename, opt_useragent, opt_type) { - var contentDisposition = opt_type ? opt_type : constants.CONTENT_DISPOSITION_ATTACHMENT; - if (opt_filename) { - contentDisposition += ';'; - if (opt_useragent != null && -1 != opt_useragent.toLowerCase().indexOf('android')) { - contentDisposition += ' filename=' + makeAndroidSafeFileName(opt_filename); - } else { - if (containsAllAsciiNP(opt_filename)) { - contentDisposition += ' filename=' + opt_filename; - } else { - contentDisposition += ' filename*=UTF-8\'\'' + encodeRFC5987ValueChars(opt_filename); - } - } - } - return contentDisposition; -} exports.getContentDisposition = getContentDisposition; -exports.getContentDispositionS3 = getContentDispositionS3; function raiseError(ro, code, msg) { ro.abort(); let error = new Error(msg);