Repository navigation
修复 #286 D4:接口令牌文件读回 embed 被 CF 注入污染 - #326
Merged
todosdev[bot] merged 1 commit intoNov 29, 2026
Merged
Conversation
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.
Summary
GET /api/read/files/<key>.html读回 embed 时,CF 会对text/html响应注入 challenge 脚本,非浏览器客户端(curl/Node fetch)无cf_clearance必拿到污染字节,照 agent-guide §11 重传即污染 R2、多轮迁移逐轮膨胀。Content-Type强制为application/octet-stream,字节即 R2 真身;图片/场景 JSON 读回保持原Content-Type不变。Changes
worker/src/routes/read.ts:文件读回端点对EMBED_KEY_RE命中者强制application/octet-stream,其余沿用 R2httpMetadata.contentType;同步更新端点 JSDoc 并加根因注释。worker/test/read-api.test.ts:embed 读回断言从text/html改为application/octet-stream,保留 read/write 双令牌逐字节一致断言。docs/agent-guide.md:§4.3 与 §11「拉取字节」各补一句,说明 embed 读回Content-Type为application/octet-stream、字节即 R2 真身(无 CF 注入),按字节原样重传即可。Testing
pnpm exec tsc --noEmit、pnpm build通过;pnpm exec vitest run test/read-api.test.ts21 用例通过;pnpm test全绿(868 单测 + 23 workers 用例)。workflow_dispatchrun46242739996,conclusion=success,head_sha=1643df7,Lint / Format / Type check / Build / Test / Check deploy config 全绿。未改授权逻辑、key 形状校验、鉴权中间件与浏览器通道(
files.ts仍按text/html+ CSP 下发)。本 diff 不含需重建的打包产物(worker build 为tsc --noEmit,web 构建产物不进仓库)。