Skip to content

Prevent Unicode bidirectional controls in terminal output - #65

Merged
mohsen1 merged 2 commits into
prooflinedev:mainfrom
scrola:main
Nov 17, 2026
Merged

mohsen1 merged 2 commits into
prooflinedev:mainfrom
scrola:main

Conversation

@scrola

@scrola scrola commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Problem

The terminal_safe function prevents terminal control characters from reaching the terminal by replacing characters recognized by Rust's char::is_control().

However, Unicode bidirectional formatting characters are not covered by this check. Characters such as Right-to-Left Override (U+202E) can change the visual ordering of terminal output without changing the underlying string.

This creates a potential security issue when displaying untrusted repository paths, filenames, or server-provided text. A malicious filename could appear different from its actual name, misleading users reviewing CLI output.

Approach

Extend the existing terminal sanitization logic to recognize the Unicode Bidirectional_Control characters:

  • U+061C
  • U+200E–U+200F
  • U+202A–U+202E
  • U+2066–U+2069

Replace these characters with the Unicode replacement character (U+FFFD), following the existing sanitization strategy.

This keeps the change localized to src/text.rs and automatically protects existing callers of terminal_safe and one_line.

Ordinary Unicode text remains unaffected.

Verification

The following tests are included:

  • Existing terminal escape-sequence sanitization.
  • Right-to-Left Override (U+202E) replacement.
  • Bidirectional isolate control replacement (U+2066, U+2069).
  • Single-line output sanitization.
  • Preservation of ordinary Unicode characters.

Run the tests with:

cargo test text::tests

Run the complete test suite with:

cargo test

Scope

  • One source file modified.
  • No new dependencies.
  • No changes to public APIs.
  • No documentation-only changes.

@scrola

scrola commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Hi! I noticed that the Proofline gate check failed because my account doesn't have a Proofline seat assigned.

Since I'm contributing as an external contributor, could you clarify whether a seat is required for community contributions, and if there's anything I need to do to get the check running?

Thanks!

@mohsen1 mohsen1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex

Reviewed the narrow terminal-output change. Corrected formatting; check and windows now pass on this head. Ordinary Unicode remains intact.

@mohsen1
mohsen1 merged commit 607fabc into prooflinedev:main Nov 17, 2026
2 of 3 checks passed
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.

2 participants