Skip to content

Commit

Permalink
Merge pull request #114 from bcgov/fix/SC-3324
Browse files Browse the repository at this point in the history
SC-3324, fix: update utils.js for RFC3986 compliant filenames
  • Loading branch information
jujaga authored Aug 22, 2023
2 parents 5275301 + 8de62b6 commit 62fe333
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion frontend/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ export function partition<T>(
*/
export function setDispositionHeader(filename: string) {
const dispositionHeader = `attachment; filename="${filename}"`;
const encodedFilename = encodeURIComponent(filename);
const encodedFilename = encodeURIComponent(filename).replace(
/[!'()*]/g,
(c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`,
);

if (filename === encodedFilename) {
return dispositionHeader;
Expand Down

0 comments on commit 62fe333

Please sign in to comment.