修复:sessionStorage 二进制控制字符 + normalizeMessagesForAPI 数组保护#594
Open
oadank wants to merge 2 commits into
Open
Conversation
Prevent null bytes (e.g. from `cat /usr/bin/ls`) from corrupting JSONL session logs by filtering control characters via a JSON.stringify replacer. Replaces \x00-\x08, \x0b, \x0c, \x0e-\x1f with safe [U+XXXX] text while preserving \n, \r, \t. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
PR quality triageChanged areas: area:cli-core CLI core policy: Blocked by policy until a maintainer applies Missing-test policy: No missing-test policy block detected. Coverage baseline policy: No coverage-baseline policy block detected. CLI core files:
Coverage policy files:
Expected checks:
Test coverage signals:
Risk notes:
Hard merge gates still come from GitHub Actions, not AI review. Dosu handoff: Dosu can be used as the AI reviewer for risk explanation, missing-test prompts, and maintainer Q&A. If it does not comment automatically from the PR template, ask: @dosubot review this PR for changed-area risk, missing tests, docs impact, desktop startup risk, and CLI core impact. |
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.
问题描述
问题 1:二进制输出破坏 JSONL session log
cat /usr/bin/ls等命令时,二进制输出(含 null bytes)进入 Bash tool stdout问题 2:LiteLLM 错误响应导致 CLI 崩溃
message.message.content可能不是数组(字符串或对象)normalizeMessagesForAPI直接调用.map()导致TypeError: content.map is not a function修复内容
Commit 1:fix(sessionStorage): sanitize binary control chars from tool output
sanitizeJsonlReplacer函数,在 JSON.stringify 时过滤控制字符-�,�,,�-�替换为[U+XXXX]文本,,(正常换行/制表符)Commit 2:fix(messages): guard against non-array content in normalizeMessagesForAPI
normalizeMessagesForAPI处理assistant消息时加Array.isArray检查[]兜底,避免.map()崩溃stripCallerFieldFromAssistantMessage里的同类问题测试情况
content.map is not a function错误合并建议
两个修复独立、无依赖关系,可以一起合并或分开审查。