Terminal Output Sanitization for Untrusted Content
Tracking ticket for RFD 096.
Implementation plan
- Build ContentWriter allowlist filter: Add
jp_term::sanitize::ContentWriter, the vte-based per-class SGR allowlist filter with span-closing reset and shared conceal removal, plus unit tests for sequence classes, chunk-split sequences, andfinish()behavior. Standalone, no behavior change until wired. - Close tool-output spans for #1201: Route tool-result bytes in
jp_cli::render::tool(render_result,render_formatted_arguments) throughContentWriterunder pass-through (off) policy, closing the span before the truncation note. Fixes the bleeding-color regression with a snapshot test. - Harden OSC embedding: Escape control characters in the strings
jp_term::oscsplices intoset_titleandhyperlinksequences, unconditional and independent of the sanitize config knob. - Add the style.sanitize config knob: Introduce
style.sanitizeinjp_config(strip/visualize/off), defaulting tostrip. - Wire sanitization into chat rendering: Apply
ContentWritertorender_request(SGR kept, span-closed),render_content/render_reasoning(SGR dropped, no span), and add the decoded-text filter injp_md::render, with snapshot tests covering escape-laden fixtures including entity-decoded escapes. - Audit and sanitize remaining render paths: Wire sanitization into tool-result, history re-render, and table/list output (
jp conversation lstitles,jp conversation grephits), ensuring width-budgeted truncation always runs on escape-free text and JP-authored chrome stays unsanitized. - Enforce plain-text tool prompts: Document and strip control characters from
jp_tool::Questiontext, pre-amble, select options, and text-answer defaults inToolPrompter, while preserving the original (unstripped) values returned to the tool. Independent of the config knob. - Document sanitization behavior: Update
docs/configuration.md, the README security section, and the ubiquitous-language glossary to describe the newstyle.sanitizeknob and disambiguate display sanitization from storage sanitization and stream repair.