b40cee18cc41a109076ea83cca639dc26b7516e5
Follow-up on the previous highway commit, addressing two real holes the Copilot review caught: * loadBinarySource HTTP path was buffering the entire response via `await resp.arrayBuffer()` BEFORE length-checking. A server that omits or understates `Content-Length` (chunked transfer, malicious upstream, proxy stripping headers) bypassed the cap entirely. Switch to a streaming reader: accumulate chunks, abort + reject as soon as the running total exceeds `maxBytes`. The Content-Length precheck still short-circuits the obvious case before we read a byte. * video-upload `stageVideoSource` has its own local-path fast-path that never went through `loadBinarySource`, so the 100 MB MAX_VIDEO_SIZE guard ran AFTER `fs.readFileSync` had already allocated the entire file. A 10 GiB local-file pointer would OOM the bot before the check fired. Add an `fs.statSync` precheck on the local branch, and pass `MAX_VIDEO_SIZE` explicitly when the source falls through to `loadBinarySource` so the HTTP / base64 cap matches the on-disk one. Update the DEFAULT_MAX_BINARY_SIZE comment to stop claiming video paths are bounded by it — they're bounded by the smaller MAX_VIDEO_SIZE, enforced inside video-upload. Adds five regression tests: - chunked streamed download (no Content-Length) over cap → throws - Content-Length over cap → throws before reading body - streamed download inside cap → returns full bytes - local file over cap (statSync precheck) → throws - base64 over cap → throws
❄️ SnowLuma
Next Remote Protocol Framework.
关于项目
项目处于开发初期,仅支持部分功能,高速迭代中,随时可能出现破坏性更新。
鸣谢
LagrangeV2 - Proto
NapCatQQ - Scaner/Packet
辅助编程
推荐 Opus4.6 + Gemini3.1pro 对本项目辅助开发
本项目大量使用Ai技术。
加入我们
Languages
TypeScript
98.9%
CSS
0.5%
JavaScript
0.5%