Repository navigation
demos: a file the agent made previews and downloads whatever it is called - #51
Merged
Merged
Conversation
…lled The two demos' preview and download routes put the file's raw name into `filename="..."`, and a header value is bytes: Node's setHeader throws ERR_INVALID_CHAR on 报告.md or an emoji, so both routes answered 500 for exactly the files a non-English agent writes. Each demo gets server/disposition.ts, the same Content-Disposition the HarnessRouter gateway sends: an ASCII stand-in every client can read plus RFC 6266 filename* with the real name, which every current browser prefers. Control characters never reach the header. tests/disposition.test.ts runs 9 names through node:http's validateHeaderValue (the check setHeader makes) for inline and attachment, and pins that the old header is the one Node refuses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
The preview and download routes in both demos (
01-cursor-coding-app,02-lumacare) put the file's raw name intoContent-Disposition: ...; filename="<name>". A header value is bytes, so Node'sres.setHeaderthrowsERR_INVALID_CHARon any character above U+00FF. A file the agent named报告.mdor🚀 launch.pnganswered 500 on both routes.The fix
Each demo gets
server/disposition.ts, the sameContent-Dispositionthe HarnessRouter gateway sends:_, and"and\are dropped)filename*=UTF-8''<percent-encoded name>, which every current browser prefersA line break can never reach the header.
Checks
tests/disposition.test.tsin each demo runs 9 names throughnode:http'svalidateHeaderValue(the checksetHeadermakes), for bothinlineandattachment. It also pins that the old header is the one Node refuses. The counts are 16 and 21 tests, the existing ones plus 10 new in each demo.npm ci,npm test,npm run build,npm audit --omit=dev --audit-level=high) all pass.express), with a client reading status and header:notes.txtnotes.txt报告.mdERR_INVALID_CHAR报告.md🚀 launch.pngERR_INVALID_CHAR🚀 launch.pngcafé (1).mdcafé (1).mdsay "hi".txtsay "hi".txtThe kits are unaffected, because none of them writes this header.
🤖 Generated with Claude Code