Skip to content

feat: harden download endpoints and document usage (#5) - #164

Open
Ratanlavate wants to merge 1 commit into
tscircuit:mainfrom
Ratanlavate:feat/harden-download-endpoints-5
Open

Ratanlavate wants to merge 1 commit into
tscircuit:mainfrom
Ratanlavate:feat/harden-download-endpoints-5

Conversation

@Ratanlavate

Copy link
Copy Markdown

Resolves #5

/claim #5

Hardens both download routes: sanitizes Content-Disposition filenames (quotes, linebreaks), serves 0-byte binary files as octet-stream instead of text, documents both URL styles in README, and adds regression tests (spaces, empty binary, 404, header sanitization).

Verification: bun test (34 pass / 0 fail), biome format clean, tsc --noEmit clean, bun run build ok.

- Add formatDownloadContentDisposition util to sanitize quote/linebreak
  characters in the Content-Disposition filename
- Serve 0-byte binary files (binary_content_b64: "") as
  application/octet-stream with Content-Length: 0 instead of falling
  back to text
- Document the /files/download query and path parameter styles in README
- Add tests covering filenames with spaces, empty binary files, 404s and
  Content-Disposition sanitization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create download endpoint /files/download?... as well as /files/download/[[file_path]]

1 participant