Skip to content

fix(input): normalize C0 control bytes on bridge-delivered interactive lines - #458

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/input-ctrl-byte-bridge
Oct 9, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/input-ctrl-byte-bridge

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

closes #434. Related: niubash#451 cluster (the hang:source:^Ucommand echo ECOSRC 0x15/NAK injection family).

Problem

A line delivered through a winpty/ConPTY bridge is an encoding of typed TEXT, not a keystroke stream: a literal \1 typed by the user reached the interactive reader as byte 0x01 and was honored as console Ctrl-A (cursor-home), silently corrupting the edit buffer (echo \x01x executed as xecho ). The sibling #451 family injected 0x15 (Ctrl-U/NAK) the same way.

Fix

One input-layer normalization, not per-byte patches: run_interactive_stdin now runs every cooked line through normalize_bridge_line before the edit dispatch. C0 control bytes (0x00-0x1F) without cooked-line semantics — cursor motion (C-a/C-e/C-b/C-f), kill (C-k/C-u), isearch (C-r), history (C-p/C-n) and the unbound rest — are dropped, so they can neither act on nor enter the command-line buffer.

Details the walk has to cover:

  • bytes_to_shell_text marker-tags the carrier bytes (0x0c/0x11/0x13 plus the whole 0x14..=0x1f block, 0x15 included) as raw-byte marker pairs; a naive char < ' ' filter re-materialized them downstream. The normalizer decodes marker pairs and drops the artifact bytes.
  • Keys that keep line-level semantics survive: Enter (CR/NL), Tab, Backspace (BS/DEL), C-c (discard line), C-d (EOF), C-v (quoted insert) and the ESC introducer, so bridge-sent arrow-key sequences are still consumed whole and their [A tails never leak into the buffer.

Tests

New tests/issue434_bridge_control_byte_regressions.rs (7 tests, all green):

  • 0x01 no longer corrupts the edit buffer (rubash#434 repro)
  • 0x15 no longer kills the buffered line; 0x15-prefixed line (the exact hang:source:^U shape) runs without hanging
  • unbound C0 artifacts (NUL/BEL/DC3/ETB/EM/SUB/FS) dropped
  • no-regression: backspace still edits; C-c/C-d keep their semantics; arrow-key escape tails never leak

Existing input-layer suites verified: issue419_console_repl_channel_regressions (8/8), marker_leak_golden (6/6), lib unit tests (624/624), cli_tests failure set byte-identical to the pre-change baseline (pre-existing environment-dependent failures only; the pb10k_prompt_channel_regressions::interactive_prompt_renders_dirtrimmed_w failure is likewise pre-existing on this branch).

@caomengxuan666
caomengxuan666 merged commit 2bfc15b into master Oct 9, 2026
7 of 8 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/input-ctrl-byte-bridge branch October 9, 2026 13:03
caomengxuan666 added a commit that referenced this pull request Oct 9, 2026
caomengxuan666 added a commit that referenced this pull request Oct 10, 2026
…#478)

- Delete docs/{TASK-BOARD,TASKBOARD,QUEUE-PROMPTS,PERF-BASELINE,CORPUS-COVERAGE,COMPATIBILITY-STATUS,LINUX-RUN-STATUS}.md: dated status snapshots / session handoffs whose content lives in git history and the issue tracker. Still-valid baseline numbers (perf table, corpus coverage, 2026-10-02 compat ledger) are excerpted into issue #477.
- AGENTS.md/README/README.zh-CN: repoint dangling references to the issue tracker.
- CHANGELOG: record SIGPIPE semantics (#455), interactive input C0 normalization (#458), and android bionic targets (#456) under Unreleased.

Co-authored-by: docs-audit <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P2][input] literal \1 byte typed via winpty bridge reaches the shell as 0x01 (console Ctrl-A) — input-layer encoding

1 participant