Reject explicit bidirectional controls in tracked sources #278

Manually merged
github merged 1 commit from gh-pr/278/head into gh-pr/278/base 2026-11-26 21:39:37 +00:00
Owner

@⁠Leyukaka on GitHub · 2026-11-21 20:09 UTC · original
Leyukaka:bidi-check → main · +102 −0 · 2 files · 1 commits · merged 2026-11-21 20:25 UTC

Change

Fixes #254, with the scope set there. tests/bidi_controls_check.py fails on the explicit bidirectional controls in Git-tracked source files, scripts and build/CI configuration. These are the embeddings and overrides U+202A to U+202E and the isolates U+2066 to U+2069. Each finding prints path:line: U+XXXX NAME. The check runs in the existing python-linux job and uses the standard library only.

In scope:

  • source files by suffix: .asm .c .cc .cpp .cxx .def .h .hh .hlsl .hlsli .hpp .inc .inl .py;
  • scripts: .bat .cmd .ps1 .psm1 .sh .cmake;
  • CMakeLists.txt, CMakePresets.json, requirements-dev.txt and .gitattributes;
  • .yml/.yaml files under .github/.

Out of scope, as requested: Markdown and other documentation, zero-width characters, UTF-8 enforcement and a binary allowlist. Files are decoded as UTF-8 with replacement, so a non-UTF-8 file is still scanned and never fails for its encoding. Lines are counted on LF only, so CRLF files and form feeds report the same line an editor shows.

Verification

On 17e7381 (branch on 496fc28), Windows 11 build 26300, Python 3.14:

python -B tests/bidi_controls_check.py
Self-test passed.
Checked 250 tracked source, script and build/CI files: no bidirectional controls.

The self-test runs first on every invocation. It writes synthetic files, byte for byte, into a temporary directory:

  • a Python file with U+202E on line 2: tools/hidden.py:2: U+202E RIGHT-TO-LEFT OVERRIDE;
  • a CRLF C++ file with a form feed and U+2066 on line 2: tests/isolate.cpp:2: U+2066 LEFT-TO-RIGHT ISOLATE;
  • a workflow file with U+202E: .github/workflows/ci.yml:1: U+202E RIGHT-TO-LEFT OVERRIDE;
  • a C++ file with ordinary non-ASCII text (64×64, café, naïve, –, ≡), which passes;
  • a Markdown file with U+202E, which is out of scope and not reported.

It also asserts that the set holds exactly the nine code points.

Negative controls, run by hand and reverted:

  • Appending U+202E to line 1 of tools/pe_inventory.py prints tools/pe_inventory.py:1: U+202E RIGHT-TO-LEFT OVERRIDE and exits 1.
  • The same character in docs/experiments.md is not reported.
  • Each of these mutations fails the self-test:
    • dropping the isolate range;
    • treating every path as in scope;
    • never matching a control;
    • adding .md to the suffixes;
    • counting lines with splitlines(), which reports line 3 for the CRLF file.

Evidence and follow-up

The script contains no literal control characters; the self-test builds them with chr().

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed. (No capability or build requirement changed.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

**@⁠Leyukaka** on GitHub · 2026-11-21 20:09 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/278) `Leyukaka:bidi-check` → `main` · +102 −0 · 2 files · 1 commits · merged 2026-11-21 20:25 UTC ## Change Fixes #254, with the scope set there. `tests/bidi_controls_check.py` fails on the explicit bidirectional controls in Git-tracked source files, scripts and build/CI configuration. These are the embeddings and overrides U+202A to U+202E and the isolates U+2066 to U+2069. Each finding prints `path:line: U+XXXX NAME`. The check runs in the existing `python-linux` job and uses the standard library only. In scope: - source files by suffix: `.asm .c .cc .cpp .cxx .def .h .hh .hlsl .hlsli .hpp .inc .inl .py`; - scripts: `.bat .cmd .ps1 .psm1 .sh .cmake`; - `CMakeLists.txt`, `CMakePresets.json`, `requirements-dev.txt` and `.gitattributes`; - `.yml`/`.yaml` files under `.github/`. Out of scope, as requested: Markdown and other documentation, zero-width characters, UTF-8 enforcement and a binary allowlist. Files are decoded as UTF-8 with replacement, so a non-UTF-8 file is still scanned and never fails for its encoding. Lines are counted on LF only, so CRLF files and form feeds report the same line an editor shows. ## Verification On `17e7381` (branch on `496fc28`), Windows 11 build 26300, Python 3.14: ```text python -B tests/bidi_controls_check.py Self-test passed. Checked 250 tracked source, script and build/CI files: no bidirectional controls. ``` The self-test runs first on every invocation. It writes synthetic files, byte for byte, into a temporary directory: - a Python file with U+202E on line 2: `tools/hidden.py:2: U+202E RIGHT-TO-LEFT OVERRIDE`; - a CRLF C++ file with a form feed and U+2066 on line 2: `tests/isolate.cpp:2: U+2066 LEFT-TO-RIGHT ISOLATE`; - a workflow file with U+202E: `.github/workflows/ci.yml:1: U+202E RIGHT-TO-LEFT OVERRIDE`; - a C++ file with ordinary non-ASCII text (`64×64`, `café`, `naïve`, `–`, `≡`), which passes; - a Markdown file with U+202E, which is out of scope and not reported. It also asserts that the set holds exactly the nine code points. Negative controls, run by hand and reverted: - Appending U+202E to line 1 of `tools/pe_inventory.py` prints `tools/pe_inventory.py:1: U+202E RIGHT-TO-LEFT OVERRIDE` and exits 1. - The same character in `docs/experiments.md` is not reported. - Each of these mutations fails the self-test: - dropping the isolate range; - treating every path as in scope; - never matching a control; - adding `.md` to the suffixes; - counting lines with `splitlines()`, which reports line 3 for the CRLF file. ## Evidence and follow-up The script contains no literal control characters; the self-test builds them with `chr()`. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [ ] I updated README/docs when a capability or build requirement changed. (No capability or build requirement changed.) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
tests/bidi_controls_check.py fails on U+202A..U+202E and U+2066..U+2069
in tracked source files, scripts and build/CI configuration, reporting
path, line and code point. It runs in the python-linux job.

Fixes #254
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:39:36 +00:00
github manually merged commit 17e73819fd into gh-pr/278/base 2026-11-26 21:39:37 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.