Skip to content

Commit

Permalink
fix: #665 url encoded filename on download
Browse files Browse the repository at this point in the history
  • Loading branch information
MontaGhanmy committed Oct 2, 2024
1 parent 8d172b5 commit f731dae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,11 @@ export class DocumentsController {
const data = archiveOrFile.file;
const filename = encodeURIComponent(data.name.replace(/[^\p{L}0-9 _.-]/gu, ""));

response.header("Content-disposition", `attachment; filename="${filename}"`);
response.header(
"Content-Disposition",
`attachment; filename="${filename}"; filename*=UTF-8''${filename}`,
);

if (data.size) response.header("Content-Length", data.size);
response.type(data.mime);
return response.send(data.file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ export class FileController {
const data = await gr.services.files.download(params.id, context);
const filename = data.name.replace(/[^a-zA-Z0-9 -_.]/g, "");

response.header("Content-disposition", `attachment; filename="${filename}"`);
response.header(
"Content-Disposition",
`attachment; filename="${filename}"; filename*=UTF-8''${filename}`,
);

if (data.size) response.header("Content-Length", data.size);
response.type(data.mime);
return response.send(data.file);
Expand Down

0 comments on commit f731dae

Please sign in to comment.