fix(doctor): strip C1 control characters from doctor error messages#103383
fix(doctor): strip C1 control characters from doctor error messages#103383lsr911 wants to merge 2 commits into
Conversation
scrubDoctorErrorMessage() used a whitelist that kept characters above 0x1f except DEL (0x7f). C1 control characters (0x80-0x9f) satisfy both conditions and pass through unfiltered into terminal output shown by openclaw doctor. Add C1 exclusion to the whitelist. Same pattern as the C1 fixes in openclaw#103226, openclaw#103274, openclaw#103379-openclaw#103382. Co-Authored-By: Claude <[email protected]>
|
Codex review: needs real behavior proof before merge. Reviewed July 11, 2026, 4:13 AM ET / 08:13 UTC. Summary PR surface: Source 0, Tests +35. Total +35 across 2 files. Reproducibility: yes. at source level with high confidence: live Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Preserve the doctor-specific 256-code-unit cap, apply the proposed C1 exclusion, retain the focused regression tests, and add redacted real-path terminal evidence before merge. Do we have a high-confidence way to reproduce the issue? Yes at source level with high confidence: live Is this the best way to solve the issue? Yes: extending the existing doctor-owned capped sanitizer is the narrowest maintainable solution and aligns it with the established terminal C0/DEL/C1 filtering invariant. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 81ce206ee84f. Label changesLabel justifications:
Evidence reviewedPR surface: Source 0, Tests +35. Total +35 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
…essage Add focused regression coverage for the C1 range (0x80-0x9f) removal: - U+009B (CSI introducer) stripped, surrounding text preserved - full C1 range 0x80-0x9f removed - printable Unicode above C1 (accented latin, CJK, emoji) preserved - C0 controls and DEL still stripped Signed-off-by: lsr911 <[email protected]>
|
Superseded by #104362 — a single sink-wide C1 (0x80–0x9f) pass that folds this sink's fix in with a valid U+009B regression, alongside an audit of every other control-character sink (already-covered / deferred / out-of-scope). This consolidates the isolated C1 PRs per the direction on #103226. Closing in favor of the consolidated review. |
…g sinks Terminal-control sanitizers guard untrusted text before it reaches a terminal or log (CWE-117). The canonical range is C0 (0x00-0x1f), DEL (0x7f), and C1 (0x80-0x9f) - the range already used by the shared sanitizeForLog and by renderTerminalBufferText (openclaw#103274). C1 includes the 8-bit CSI introducer U+009B. Deliberate sink-wide pass: closes the C1 gap in twelve terminal/log output sinks, each keeping its own strip/escape/replace/truncate/reject action and gaining a focused valid-U+009B regression test. The PR body audits every other control-char sink (already-covered, deferred, or out-of-scope). Consolidates the isolated PRs openclaw#103379 openclaw#103380 openclaw#103381 openclaw#103382 openclaw#103383 openclaw#103402 Signed-off-by: lsr911 <[email protected]> openclaw#103405 and re-lands the sanitizeForConsole fix from openclaw#103226 cleanly.
What Problem This Solves
scrubDoctorErrorMessage()insrc/flows/doctor-error-message.tsstrips control characters before doctor/lint/repair errors are printed to the terminal, but it only removed the C0 range (0x00-0x1f) and DEL (0x7f). It did not remove the C1 control range (0x80-0x9f), which includes the CSI introducer U+009B — an alternative ANSI escape prefix equivalent toESC [. A C1-bearing error message could therefore reach the terminal and drive cursor/color escapes.Change
Extend the existing predicate to also drop 0x80-0x9f:
Same C1 completion Peter merged for
renderTerminalBufferTextin #103274 ("Extended the existing terminal-text residual filter through DEL/C1 while preserving tabs").Testing / Proof
Added a focused regression test
src/flows/doctor-error-message.test.tsthat calls the realscrubDoctorErrorMessageand asserts:The test exercises the modified function directly, so the passing run demonstrates the exact before/after behavior: on current
mainthe U+009B and full-C1 cases fail (bytes retained), and with this change they are removed while ordinary Unicode survives.