Skip to content

Commit

Permalink
fix: escape the Content-Disposition header properly
Browse files Browse the repository at this point in the history
  • Loading branch information
izatop committed Nov 21, 2024
1 parent 8b3651b commit c27a2bb
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 65 deletions.
5 changes: 3 additions & 2 deletions packages/web/src/Transport/Response/DownloadResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {join} from "path";
import {isString, isUndefined} from "@bunt/is";
import {Defer} from "@bunt/async";
import {ResponseAbstract, ResponseArgs} from "./ResponseAbstract.js";
import { escape } from "querystring";

type DownloadSource = string | Readable;
type DownloadOptions = {
Expand Down Expand Up @@ -37,9 +38,9 @@ function createHeaders(options: DownloadOptions): Record<string, string> {
const size = options.size;
const attributes = [
"attachment",
`filename="${encodeURI(options.filename)}"`,
`filename="${escape(options.filename)}"`,
// Safari https://datatracker.ietf.org/doc/html/rfc5987#section-3.2.2
`filename*=utf-8''${encodeURI(options.filename)}`,
`filename*=utf-8''${escape(options.filename)}`,
];

const headers: Record<string, string> = {
Expand Down
126 changes: 63 additions & 63 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -406,48 +406,48 @@ __metadata:
languageName: node
linkType: hard

"@bunt/app@npm:^0.31.0, @bunt/app@workspace:packages/app":
"@bunt/app@npm:^0.32.0, @bunt/app@workspace:packages/app":
version: 0.0.0-use.local
resolution: "@bunt/app@workspace:packages/app"
dependencies:
"@bunt/assert": "npm:^0.31.0"
"@bunt/async": "npm:^0.31.0"
"@bunt/input": "npm:^0.31.0"
"@bunt/is": "npm:^0.31.0"
"@bunt/unit": "npm:^0.31.0"
"@bunt/util": "npm:^0.31.0"
"@bunt/assert": "npm:^0.32.0"
"@bunt/async": "npm:^0.32.0"
"@bunt/input": "npm:^0.32.0"
"@bunt/is": "npm:^0.32.0"
"@bunt/unit": "npm:^0.32.0"
"@bunt/util": "npm:^0.32.0"
"@types/busboy": "npm:^1.5.4"
busboy: "npm:^1.6.0"
path-to-regexp: "npm:^8.2.0"
languageName: unknown
linkType: soft

"@bunt/assert@npm:^0.31.0, @bunt/assert@workspace:packages/assert":
"@bunt/assert@npm:^0.32.0, @bunt/assert@workspace:packages/assert":
version: 0.0.0-use.local
resolution: "@bunt/assert@workspace:packages/assert"
dependencies:
"@bunt/is": "npm:^0.31.0"
"@bunt/type": "npm:^0.31.0"
"@bunt/is": "npm:^0.32.0"
"@bunt/type": "npm:^0.32.0"
languageName: unknown
linkType: soft

"@bunt/async@npm:^0.31.0, @bunt/async@workspace:packages/async":
"@bunt/async@npm:^0.32.0, @bunt/async@workspace:packages/async":
version: 0.0.0-use.local
resolution: "@bunt/async@workspace:packages/async"
dependencies:
"@bunt/assert": "npm:^0.31.0"
"@bunt/is": "npm:^0.31.0"
"@bunt/type": "npm:^0.31.0"
"@bunt/assert": "npm:^0.32.0"
"@bunt/is": "npm:^0.32.0"
"@bunt/type": "npm:^0.32.0"
languageName: unknown
linkType: soft

"@bunt/cli@workspace:packages/cli":
version: 0.0.0-use.local
resolution: "@bunt/cli@workspace:packages/cli"
dependencies:
"@bunt/app": "npm:^0.31.0"
"@bunt/assert": "npm:^0.31.0"
"@bunt/util": "npm:^0.31.0"
"@bunt/app": "npm:^0.32.0"
"@bunt/assert": "npm:^0.32.0"
"@bunt/util": "npm:^0.32.0"
path-to-regexp: "npm:^8.2.0"
languageName: unknown
linkType: soft
Expand All @@ -456,50 +456,50 @@ __metadata:
version: 0.0.0-use.local
resolution: "@bunt/date@workspace:packages/date"
dependencies:
"@bunt/assert": "npm:^0.31.0"
"@bunt/is": "npm:^0.31.0"
"@bunt/assert": "npm:^0.32.0"
"@bunt/is": "npm:^0.32.0"
languageName: unknown
linkType: soft

"@bunt/fs@workspace:packages/fs":
version: 0.0.0-use.local
resolution: "@bunt/fs@workspace:packages/fs"
dependencies:
"@bunt/assert": "npm:^0.31.0"
"@bunt/is": "npm:^0.31.0"
"@bunt/unit": "npm:^0.31.0"
"@bunt/assert": "npm:^0.32.0"
"@bunt/is": "npm:^0.32.0"
"@bunt/unit": "npm:^0.32.0"
"@types/minio": "npm:^7.1.1"
"@types/node-fetch": "npm:^2.6.11"
minio: "npm:^7.1.3"
node-fetch: "npm:2.7.0"
languageName: unknown
linkType: soft

"@bunt/input@npm:^0.31.0, @bunt/input@workspace:packages/input":
"@bunt/input@npm:^0.32.0, @bunt/input@workspace:packages/input":
version: 0.0.0-use.local
resolution: "@bunt/input@workspace:packages/input"
dependencies:
"@bunt/assert": "npm:^0.31.0"
"@bunt/is": "npm:^0.31.0"
"@bunt/type": "npm:^0.31.0"
"@bunt/assert": "npm:^0.32.0"
"@bunt/is": "npm:^0.32.0"
"@bunt/type": "npm:^0.32.0"
languageName: unknown
linkType: soft

"@bunt/is@npm:^0.31.0, @bunt/is@workspace:packages/is":
"@bunt/is@npm:^0.32.0, @bunt/is@workspace:packages/is":
version: 0.0.0-use.local
resolution: "@bunt/is@workspace:packages/is"
dependencies:
"@bunt/type": "npm:^0.31.0"
"@bunt/type": "npm:^0.32.0"
languageName: unknown
linkType: soft

"@bunt/queue@workspace:packages/queue":
version: 0.0.0-use.local
resolution: "@bunt/queue@workspace:packages/queue"
dependencies:
"@bunt/async": "npm:^0.31.0"
"@bunt/unit": "npm:^0.31.0"
"@bunt/util": "npm:^0.31.0"
"@bunt/async": "npm:^0.32.0"
"@bunt/unit": "npm:^0.32.0"
"@bunt/util": "npm:^0.32.0"
ioredis: "npm:^5.4.1"
languageName: unknown
linkType: soft
Expand All @@ -508,53 +508,53 @@ __metadata:
version: 0.0.0-use.local
resolution: "@bunt/task@workspace:packages/task"
dependencies:
"@bunt/assert": "npm:^0.31.0"
"@bunt/async": "npm:^0.31.0"
"@bunt/is": "npm:^0.31.0"
"@bunt/type": "npm:^0.31.0"
"@bunt/unit": "npm:^0.31.0"
"@bunt/assert": "npm:^0.32.0"
"@bunt/async": "npm:^0.32.0"
"@bunt/is": "npm:^0.32.0"
"@bunt/type": "npm:^0.32.0"
"@bunt/unit": "npm:^0.32.0"
languageName: unknown
linkType: soft

"@bunt/type@npm:^0.31.0, @bunt/type@workspace:packages/type":
"@bunt/type@npm:^0.32.0, @bunt/type@workspace:packages/type":
version: 0.0.0-use.local
resolution: "@bunt/type@workspace:packages/type"
languageName: unknown
linkType: soft

"@bunt/unit@npm:^0.31.0, @bunt/unit@workspace:packages/unit":
"@bunt/unit@npm:^0.32.0, @bunt/unit@workspace:packages/unit":
version: 0.0.0-use.local
resolution: "@bunt/unit@workspace:packages/unit"
dependencies:
"@bunt/assert": "npm:^0.31.0"
"@bunt/async": "npm:^0.31.0"
"@bunt/is": "npm:^0.31.0"
"@bunt/type": "npm:^0.31.0"
"@bunt/util": "npm:^0.31.0"
"@bunt/assert": "npm:^0.32.0"
"@bunt/async": "npm:^0.32.0"
"@bunt/is": "npm:^0.32.0"
"@bunt/type": "npm:^0.32.0"
"@bunt/util": "npm:^0.32.0"
languageName: unknown
linkType: soft

"@bunt/util@npm:^0.31.0, @bunt/util@workspace:packages/util":
"@bunt/util@npm:^0.32.0, @bunt/util@workspace:packages/util":
version: 0.0.0-use.local
resolution: "@bunt/util@workspace:packages/util"
dependencies:
"@bunt/assert": "npm:^0.31.0"
"@bunt/async": "npm:^0.31.0"
"@bunt/is": "npm:^0.31.0"
"@bunt/type": "npm:^0.31.0"
"@bunt/assert": "npm:^0.32.0"
"@bunt/async": "npm:^0.32.0"
"@bunt/is": "npm:^0.32.0"
"@bunt/type": "npm:^0.32.0"
languageName: unknown
linkType: soft

"@bunt/web@npm:^0.31.0, @bunt/web@workspace:packages/web":
"@bunt/web@npm:^0.32.0, @bunt/web@workspace:packages/web":
version: 0.0.0-use.local
resolution: "@bunt/web@workspace:packages/web"
dependencies:
"@bunt/app": "npm:^0.31.0"
"@bunt/assert": "npm:^0.31.0"
"@bunt/async": "npm:^0.31.0"
"@bunt/is": "npm:^0.31.0"
"@bunt/type": "npm:^0.31.0"
"@bunt/util": "npm:^0.31.0"
"@bunt/app": "npm:^0.32.0"
"@bunt/assert": "npm:^0.32.0"
"@bunt/async": "npm:^0.32.0"
"@bunt/is": "npm:^0.32.0"
"@bunt/type": "npm:^0.32.0"
"@bunt/util": "npm:^0.32.0"
http-status: "npm:^1.7.4"
path-to-regexp: "npm:^8.2.0"
languageName: unknown
Expand All @@ -564,14 +564,14 @@ __metadata:
version: 0.0.0-use.local
resolution: "@bunt/ws@workspace:packages/ws"
dependencies:
"@bunt/app": "npm:^0.31.0"
"@bunt/assert": "npm:^0.31.0"
"@bunt/async": "npm:^0.31.0"
"@bunt/is": "npm:^0.31.0"
"@bunt/type": "npm:^0.31.0"
"@bunt/unit": "npm:^0.31.0"
"@bunt/util": "npm:^0.31.0"
"@bunt/web": "npm:^0.31.0"
"@bunt/app": "npm:^0.32.0"
"@bunt/assert": "npm:^0.32.0"
"@bunt/async": "npm:^0.32.0"
"@bunt/is": "npm:^0.32.0"
"@bunt/type": "npm:^0.32.0"
"@bunt/unit": "npm:^0.32.0"
"@bunt/util": "npm:^0.32.0"
"@bunt/web": "npm:^0.32.0"
"@types/websocket": "npm:^1.0.10"
"@types/ws": "npm:^8.5.12"
websocket: "npm:^1.0.35"
Expand Down

0 comments on commit c27a2bb

Please sign in to comment.