Skip to content

fix download for file names with non-ascii chars or quotes - #192

Open
sainath998 wants to merge 1 commit into
tscircuit:mainfrom
sainath998:fix/download-filename-header
Open

sainath998 wants to merge 1 commit into
tscircuit:mainfrom
sainath998:fix/download-filename-header

Conversation

@sainath998

@sainath998 sainath998 commented Nov 13, 2026 •

Copy link
Copy Markdown

/claim #5

Both download routes put the raw file name into Content-Disposition. A name like 日本語.txt threw "Header has invalid value" and the request 500'd, and a quote in the name produced a broken header. Add filename* (RFC 6266) when needed and share the response code between the two routes.

Before (main):

GET /files/download?file_path=日本語.txt  -> 500 Internal Server Error
GET /files/download/日本語.txt            -> 500 Internal Server Error
GET /files/download?file_path=say "hi".txt -> 200, content-disposition: attachment; filename="say "hi".txt"

After:

GET /files/download?file_path=日本語.txt  -> 200, content-disposition: attachment; filename="___.txt"; filename*=UTF-8''%E6%97%A5%E6%9C%AC%E8%AA%9E.txt
GET /files/download/日本語.txt            -> 200, same header
GET /files/download?file_path=say "hi".txt -> 200, content-disposition: attachment; filename="say _hi_.txt"; filename*=UTF-8''say%20%22hi%22.txt

Demo:

demo

Both download routes put the raw file name into Content-Disposition.
A name like 日本語.txt threw "Header has invalid value" and the request
500'd, and a quote in the name produced a broken header. Add
filename* (RFC 6266) when needed and share the response code between
the two routes.
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.

1 participant