From b4cf34bf597000fb61dcc55fb03a7d3734c2174b Mon Sep 17 00:00:00 2001 From: Alexander Saxon <0x00000000DE4DB33F@proton.me> Date: Fri, 1 Dec 2023 00:13:06 +0200 Subject: [PATCH] Fix net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION error When the filename contains a comma, the above error error occurs when trying to download a file. The solution is to enclose the filename in quotes. --- src/http/api/routes/file/download.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/http/api/routes/file/download.js b/src/http/api/routes/file/download.js index 1a06b73..b29018b 100644 --- a/src/http/api/routes/file/download.js +++ b/src/http/api/routes/file/download.js @@ -49,7 +49,7 @@ module.exports.handler = async (req, reply) => { const resHeaders = { 'Content-Length': file.size, 'Accept-Ranges': 'bytes', - 'Content-Disposition': `attachment; filename=${encodeURI(file.name)}`, + 'Content-Disposition': `attachment; filename="${encodeURI(file.name)}"`, } const mimeType = mime.lookup(path.extname(file.name)) if (mimeType) resHeaders['Content-Type'] = mimeType