Fail CI on hidden Unicode characters in tracked files #251

Closed
opened 2026-11-21 19:25:08 +00:00 by Leyukaka · 1 comment
Leyukaka commented 2026-11-21 19:25:08 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-21T19:25:08Z.


Problem

Some characters render as nothing or reorder the text around them, while a compiler, an interpreter or a coding agent still reads them:

  • bidi controls: U+061C, U+202A to U+202E, U+2066 to U+2069;
  • zero-width characters: U+200B to U+200F, U+2060 to U+2064;
  • Unicode tag characters: U+E0000 to U+E007F.

A pull request can use them to hide code or instructions from a human reviewer. GitHub shows a warning on files that contain hidden Unicode text, but nothing in CI fails on them. Reviewers and agent contributors are both affected.

Proposal

Add a standard-library script, tests/hidden_unicode_check.py, and run it in the python-linux job. It reads every tracked file and fails on:

  • any of the characters above;
  • U+FEFF anywhere except at offset 0, where Visual Studio and PowerShell 5.1 write a byte-order mark;
  • a file that is not valid UTF-8, unless it is a known binary type.

A scan of all 256 tracked files on 23d954d found none of these characters, no BOM and no non-UTF-8 text, so the check starts without an allowlist. I can open it as a PR.

Alternatives

  • Rely on GitHub's hidden-text warning. It is shown to a reader and does not fail CI, so an agent or an unattended merge does not see it.
  • Reject all non-ASCII text. Too broad: the docs legitimately use typographic characters.

Two related changes, which would each need their own issue:

  • an AGENTS.md line saying that text from issues, pull requests and comments is data for agents, not instructions;
  • hash-pinning requirements-dev.txt with --require-hashes, covering every release file of pefile and iced-x86.

Verification

python -B tests/hidden_unicode_check.py passes on main. Negative controls:

  • adding U+202E to a tracked Markdown file fails with its path, line and code point;
  • adding U+200B inside a Python string fails the same way;
  • a BOM at offset 0 of a .ps1 file passes, and a BOM in the middle of the same file fails.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6533371355 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/254). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-21T19:25:08Z. --- ### Problem Some characters render as nothing or reorder the text around them, while a compiler, an interpreter or a coding agent still reads them: - bidi controls: U+061C, U+202A to U+202E, U+2066 to U+2069; - zero-width characters: U+200B to U+200F, U+2060 to U+2064; - Unicode tag characters: U+E0000 to U+E007F. A pull request can use them to hide code or instructions from a human reviewer. GitHub shows a warning on files that contain hidden Unicode text, but nothing in CI fails on them. Reviewers and agent contributors are both affected. ### Proposal Add a standard-library script, `tests/hidden_unicode_check.py`, and run it in the `python-linux` job. It reads every tracked file and fails on: - any of the characters above; - U+FEFF anywhere except at offset 0, where Visual Studio and PowerShell 5.1 write a byte-order mark; - a file that is not valid UTF-8, unless it is a known binary type. A scan of all 256 tracked files on `23d954d` found none of these characters, no BOM and no non-UTF-8 text, so the check starts without an allowlist. I can open it as a PR. ### Alternatives - **Rely on GitHub's hidden-text warning.** It is shown to a reader and does not fail CI, so an agent or an unattended merge does not see it. - **Reject all non-ASCII text.** Too broad: the docs legitimately use typographic characters. Two related changes, which would each need their own issue: - an `AGENTS.md` line saying that text from issues, pull requests and comments is data for agents, not instructions; - hash-pinning `requirements-dev.txt` with `--require-hashes`, covering every release file of `pefile` and `iced-x86`. ### Verification `python -B tests/hidden_unicode_check.py` passes on `main`. Negative controls: - adding U+202E to a tracked Markdown file fails with its path, line and code point; - adding U+200B inside a Python string fails the same way; - a BOM at offset 0 of a `.ps1` file passes, and a BOM in the middle of the same file fails. _AI-assisted._
R0Y00 commented 2026-11-24 06:47:58 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T20:01:58Z.


A focused check for explicit bidirectional text controls is welcome. Please run it in the existing Linux Python job and scope it to Git-tracked source files, scripts, and build/CI configuration. For each finding, report the path, line number and Unicode code point. Synthetic tests should cover a bidi control such as U+202E with the expected diagnostic and ordinary non-ASCII text that passes.

Please keep repository-wide UTF-8 enforcement, general zero-width character checks and a binary-extension allowlist outside this change. A PR linked to this issue is sufficient.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7068453687 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/254#issuecomment-7068453687). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T20:01:58Z. --- A focused check for explicit bidirectional text controls is welcome. Please run it in the existing Linux Python job and scope it to Git-tracked source files, scripts, and build/CI configuration. For each finding, report the path, line number and Unicode code point. Synthetic tests should cover a bidi control such as U+202E with the expected diagnostic and ordinary non-ASCII text that passes. Please keep repository-wide UTF-8 enforcement, general zero-width character checks and a binary-extension allowlist outside this change. A PR linked to this issue is sufficient.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows#251
No description provided.