Skip to content

CRITICAL: TUI panics on ESC followed by a multi-byte char in raw bash output #240

Description

@robertohluna

priv/rust/tui/src/render/sanitize.rs:153 slices mid-codepoint. escape_len_at returns Some(2) for the catch-all two-byte escape (util.rs:107); when the byte after ESC is a UTF-8 lead byte, rest = &rest[len..] splits a character.

Reproduced against the real crate through the bash-output render path:

panicked at src/render/sanitize.rs:153:
byte index 2 is not a char boundary; it is inside '✓' (bytes 1..4) of `✓ done`

Reachable from tools/bash.rs:90collapse::enhanced_output_linesnormalized_output_rowsscrub_terminal_output, i.e. raw unsanitized tool output. A printf '\033✓', a clipped ANSI sequence in a log, or a partially-read binary aborts the user's TUI session.

scrub_terminal_output is the first consumer of raw ESC bytes, which is why this is new. scrub_untrusted_document filters by chars() and is char-safe.

Fix: advance by whole chars — clamp len up to the next is_char_boundary, or drive the loop with char_indices.

Shipped knowingly in v1.0.177.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions