Reject explicit bidirectional controls in tracked sources #274

Merged
Leyukaka merged 1 commit from upstream-pr/278 into main 2026-11-21 20:25:46 +00:00
Leyukaka commented 2026-11-21 20:09:58 +00:00 (Migrated from github.com)

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


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6533814729 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/278). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-21T20:09:58Z. --- ## 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.
upstream-sync closed this pull request 2026-11-24 06:42:11 +00:00
Sign in to join this conversation.
No reviewers
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!274
No description provided.