launchers: command-line arguments keep a folder's last backslash (GAME-GATE-START-QUOTING) #3257

Manually merged
github merged 1 commit from github-bot/gh-3257 into gh-pr/3257/base 2026-12-03 15:46:14 +00:00 AGit
Owner

@⁠LouisRiverstone on GitHub · 2026-12-02 22:50 UTC · original
LouisRiverstone:fix/game-gate-start-quoting → main · +102 −2 · 3 files · 1 commits · merged 2026-12-03 15:39 UTC

Claim: #2570 (GAME-GATE-START-QUOTING)

What and why

Two launchers build a Windows command line by quoting each argument as '"' + ($s -replace '"', '\"') + '"'. Windows reads a command line back by CommandLineToArgvW's rules, where a backslash in front of a quote escapes that quote. So:

  • scripts/game-gate.ps1:103, the start verb (the detached supervisor, made through Win32_Process Create): -RunRoot D:\runs\ became "D:\runs\", which reads as D:\runs" plus every argument after it. The same happened to -More or -PlayArgs text holding a backslash before a quote.
  • d3d12/scripts/play-nvidia.ps1:808, the button-prompt tool's arguments: a -PcGlyphs folder such as C:\My glyphs\ swallowed its closing quote in the same way.

What changed

  • Both use the standard rule: the backslashes in front of a " are doubled, plus one for the quote, and the backslashes before the closing quote are doubled. \z is used, not $, so a value ending in a newline is not mistaken for one ending in backslashes. play-nvidia.ps1 also quotes an empty argument as "" so it is not dropped. The tool's arguments are never empty today, but the rule is now complete.
  • tests/test_game_gate_start_quoting.py runs each script's own quoting line on awkward values: a trailing backslash, two trailing backslashes, embedded quotes, a backslash before an embedded quote, spaces, and an empty value. It parses the joined line back with CommandLineToArgvW itself (ctypes) and checks every value comes back as one argument.

Verification (Windows 11, Windows PowerShell 5.1, Python 3.11; no game files, no GPU needed)

  • Red/green by hand: with both .ps1 changes reverted, both tests fail. D:\runs\ comes back as D:\runs" -Arg C:\Program, and the following arguments merge. With the change, both pass.
  • tests/test_win_launchers.py and tests/test_game_gate.py still pass.
  • python -I scripts/check_no_game_data.py on the three files: exit 0. Both .ps1 stay CRLF and ASCII; the test is LF and ASCII.

play-nvidia.ps1:808 is far from the lines #3233, #3240 and #3253 touch; it merges with them in any order.

AI assistance

AI-assisted: written with Claude Code (Claude Opus 5.5). It was reviewed by a separate read-only reviewer agent (Claude Opus 5.5), which confirmed the rule is the standard argv-quoting algorithm, that pwsh's argument parsing agrees with CommandLineToArgvW here, and that no other call site in scripts/, d3d12/scripts/ or tools/ uses this naive quoting. It found nothing blocking. Following its notes, I switched to \z, extended the fix to play-nvidia.ps1:808, and hardened the test's ctypes calls.

**@⁠LouisRiverstone** on GitHub · 2026-12-02 22:50 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3257) `LouisRiverstone:fix/game-gate-start-quoting` → `main` · +102 −2 · 3 files · 1 commits · merged 2026-12-03 15:39 UTC Claim: https://git.gtahub.st/github/ubiquitarianism--leonida/issues/2570 (GAME-GATE-START-QUOTING) ### What and why Two launchers build a Windows command line by quoting each argument as `'"' + ($s -replace '"', '\"') + '"'`. Windows reads a command line back by `CommandLineToArgvW`'s rules, where a backslash in front of a quote escapes that quote. So: - `scripts/game-gate.ps1:103`, the `start` verb (the detached supervisor, made through `Win32_Process` Create): `-RunRoot D:\runs\` became `"D:\runs\"`, which reads as `D:\runs"` plus every argument after it. The same happened to `-More` or `-PlayArgs` text holding a backslash before a quote. - `d3d12/scripts/play-nvidia.ps1:808`, the button-prompt tool's arguments: a `-PcGlyphs` folder such as `C:\My glyphs\` swallowed its closing quote in the same way. ### What changed - Both use the standard rule: the backslashes in front of a `"` are doubled, plus one for the quote, and the backslashes before the closing quote are doubled. `\z` is used, not `$`, so a value ending in a newline is not mistaken for one ending in backslashes. `play-nvidia.ps1` also quotes an empty argument as `""` so it is not dropped. The tool's arguments are never empty today, but the rule is now complete. - `tests/test_game_gate_start_quoting.py` runs each script's own quoting line on awkward values: a trailing backslash, two trailing backslashes, embedded quotes, a backslash before an embedded quote, spaces, and an empty value. It parses the joined line back with `CommandLineToArgvW` itself (ctypes) and checks every value comes back as one argument. ### Verification (Windows 11, Windows PowerShell 5.1, Python 3.11; no game files, no GPU needed) - Red/green by hand: with both `.ps1` changes reverted, both tests fail. `D:\runs\` comes back as `D:\runs" -Arg C:\Program`, and the following arguments merge. With the change, both pass. - `tests/test_win_launchers.py` and `tests/test_game_gate.py` still pass. - `python -I scripts/check_no_game_data.py` on the three files: exit 0. Both `.ps1` stay CRLF and ASCII; the test is LF and ASCII. `play-nvidia.ps1:808` is far from the lines #3233, #3240 and #3253 touch; it merges with them in any order. ### AI assistance AI-assisted: written with Claude Code (Claude Opus 5.5). It was reviewed by a separate read-only reviewer agent (Claude Opus 5.5), which confirmed the rule is the standard argv-quoting algorithm, that pwsh's argument parsing agrees with `CommandLineToArgvW` here, and that no other call site in `scripts/`, `d3d12/scripts/` or `tools/` uses this naive quoting. It found nothing blocking. Following its notes, I switched to `\z`, extended the fix to `play-nvidia.ps1:808`, and hardened the test's ctypes calls.
game-gate.ps1's start verb, and play-nvidia.ps1 for the button-prompt
tool, quoted each argument of a Windows command line as '"' + value
with " turned into \" + '"'. By CommandLineToArgvW's rules a backslash
in front of a quote escapes it, so -RunRoot D:\runs\ reached the
supervisor as D:\runs" followed by every later argument, and a
-PcGlyphs folder such as "C:\My glyphs\" did the same to the tool.

The backslashes in front of a quote or of the closing quote are now
doubled, and play-nvidia.ps1 quotes an empty argument as "" too.
tests/test_game_gate_start_quoting.py runs each script's own quoting on
awkward values and parses the joined line back with CommandLineToArgvW;
both cases fail on the base scripts.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 22:52:18 +00:00
Author
Owner

@⁠merzleckeier on GitHub · 2026-12-02 22:53 UTC · original · reviewed

Reviewed 47688d9d. I ran both exact quoting expressions with Linux PowerShell 7.7.0. On Wine 11.22, seven synthetic values for each expression round-tripped through CommandLineToArgvW and reached a spawned Windows Python process as the original argv. The fixture includes paths with spaces and one or two trailing backslashes, an empty argument, and a value with a newline. This covers argument serialization and process parsing, with no Wine game launch or supervisor run.

I also checked clean merges with #3233 at 86e92f66, #3240 at 3de2d360, and #3253 at 51bb0da2.

**@⁠merzleckeier** on GitHub · 2026-12-02 22:53 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3257#pullrequestreview-6160471760) · **reviewed** Reviewed `47688d9d`. I ran both exact quoting expressions with Linux PowerShell 7.7.0. On Wine 11.22, seven synthetic values for each expression round-tripped through `CommandLineToArgvW` and reached a spawned Windows Python process as the original argv. The fixture includes paths with spaces and one or two trailing backslashes, an empty argument, and a value with a newline. This covers argument serialization and process parsing, with no Wine game launch or supervisor run. I also checked clean merges with #3233 at `86e92f66`, #3240 at `3de2d360`, and #3253 at `51bb0da2`.
Author
Owner

@⁠fiestorra on GitHub · 2026-12-03 00:08 UTC · original

VERIFY-3257 — Windows nativo: red then green en la barra final de una carpeta

Own commit 47688d9d7 — play-nvidia.ps1 (6), game-gate.ps1 (4), tests/test_game_gate_start_quoting.py (+94)

Ran at the head

python -I tests/test_game_gate_start_quoting.py     2 tests — OK
python -I tests/test_win_launchers.py               9 tests — OK

Negative control: main's two scripts back, tests kept:

FAIL: test_the_gate_start_hands_each_value_back_as_one_argument
FAIL: test_the_glyph_tools_arguments_come_back_as_given

It bites.

What the change is: a command-line argument keeps the last backslash of a folder — C:\Games\ passed to a child loses its trailing \, or worse, the \" sequence turns the backslash into an escape and eats the quote. Both halves are the classic quoting trap on Windows, and the test asserts "each value back as one argument", which is the property — not the characters.

Why this one, #3253 and #3258 are one family and should be read together: all three are "a value that the launcher passes to a child and the child does not get back" — a path with a space, a value with a quote, a folder with a trailing separator. None of them is visible in a normal run, which is why they survived until someone's folder had a space in it.

What I could not test

  • A launch with a folder ending in a backslash: the tests read the generated command line back through a parser.

Written with an AI assistant.

**@⁠fiestorra** on GitHub · 2026-12-03 00:08 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3257#issuecomment-7362842221) ## VERIFY-3257 — Windows nativo: `red then green` en la barra final de una carpeta | | | |---|---| | Own commit | `47688d9d7` — `play-nvidia.ps1` (6), `game-gate.ps1` (4), `tests/test_game_gate_start_quoting.py` (+94) | **Ran at the head** ``` python -I tests/test_game_gate_start_quoting.py 2 tests — OK python -I tests/test_win_launchers.py 9 tests — OK ``` **Negative control**: `main`'s two scripts back, tests kept: ``` FAIL: test_the_gate_start_hands_each_value_back_as_one_argument FAIL: test_the_glyph_tools_arguments_come_back_as_given ``` **It bites.** **What the change is**: **a command-line argument keeps the last backslash of a folder** — `C:\Games\` passed to a child **loses its trailing `\`, or worse, the `\"` sequence turns the backslash into an escape and eats the quote.** **Both halves are the classic quoting trap on Windows**, and the test asserts **"each value back as one argument"**, which is the property — not the characters. **Why this one, #3253 and #3258 are one family and should be read together**: all three are **"a value that the launcher passes to a child and the child does not get back"** — **a path with a space, a value with a quote, a folder with a trailing separator.** **None of them is visible in a normal run**, **which is why they survived until someone's folder had a space in it.** ## What I could not test - **A launch with a folder ending in a backslash**: the tests read the generated command line back through a parser. Written with an AI assistant.
github-bot force-pushed github-bot/gh-3257 from 47688d9d79 to 3bc1c333ef 2026-12-03 02:25:25 +00:00 Compare
Author
Owner

@⁠lixonik on GitHub · 2026-12-03 06:31 UTC · original

Windows native verification (red -> green) -- PASS on head 3bc1c333e (merged cleanly via git merge --no-ff onto main d9b618f10).

Checks (Windows 10 x64, Python 3.12, PowerShell 5.1)

  • python -I scripts/check_no_game_data.py -> PASS
  • Green:
    • python -I tests/test_game_gate_start_quoting.py -v -> Ran 2 tests in 0.447s / OK
  • Red (reverted d3d12/scripts/play-nvidia.ps1, scripts/game-gate.ps1 to main d9b618f10, keeping the PR's tests):
    • tests/test_game_gate_start_quoting.py -> Ran 2 tests in 0.439s / FAILED (failures=2) (exit 1)

AI-assisted: yes (Antigravity -- Gemini 4 Neon).

**@⁠lixonik** on GitHub · 2026-12-03 06:31 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3257#issuecomment-7369932348) **Windows native verification (`red -> green`) -- PASS** on head `3bc1c333e` (merged cleanly via `git merge --no-ff` onto `main` `d9b618f10`). ### Checks (Windows 10 x64, Python 3.12, PowerShell 5.1) - `python -I scripts/check_no_game_data.py` -> **PASS** - **Green:** - `python -I tests/test_game_gate_start_quoting.py -v` -> **Ran 2 tests in 0.447s / OK** - **Red** (reverted `d3d12/scripts/play-nvidia.ps1`, `scripts/game-gate.ps1` to `main` `d9b618f10`, keeping the PR's tests): - `tests/test_game_gate_start_quoting.py` -> **Ran 2 tests in 0.439s / FAILED (failures=2)** (exit `1`) AI-assisted: yes (Antigravity -- Gemini 4 Neon).
Author
Owner

@⁠MoonEyes on GitHub · 2026-12-03 15:26 UTC · original

In-game gate run on an RTX 4060 8 GB (driver 610.88, Windows 11), in a batch of #3220, #3240, #3253 and #3257 merged into main b053a1813; this PR tested at its current head 3bc1c333e. Series S 1080, DLSS FG 2x, launched through play-nvidia.ps1 with -SeriesS -Resolution 1080 -FrameGen 2 -PrecompileUsed, scripted walk, 330 s.

  • Result: PASS. No device lost, no crash, no unhandled exception; the run ended on its time limit.
  • Median over the last 240 s: 17.3 fps (main alone today: 16-17.5); 19.9 frames per 1000 over 100 ms.
  • Not covered: the F1 menu was not pressed by hand, and this does not test the specific path the PR changes beyond a normal launch.

AI-assisted (Claude Opus 5.5), run and read by MoonEyes' agent.

**@⁠MoonEyes** on GitHub · 2026-12-03 15:26 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3257#issuecomment-7383158345) In-game gate run on an RTX 4060 8 GB (driver 610.88, Windows 11), in a batch of #3220, #3240, #3253 and #3257 merged into main `b053a1813`; this PR tested at its current head `3bc1c333e`. Series S 1080, DLSS FG 2x, launched through `play-nvidia.ps1` with `-SeriesS -Resolution 1080 -FrameGen 2 -PrecompileUsed`, scripted walk, 330 s. - Result: **PASS**. No device lost, no crash, no unhandled exception; the run ended on its time limit. - Median over the last 240 s: 17.3 fps (main alone today: 16-17.5); 19.9 frames per 1000 over 100 ms. - Not covered: the F1 menu was not pressed by hand, and this does not test the specific path the PR changes beyond a normal launch. AI-assisted (Claude Opus 5.5), run and read by MoonEyes' agent.
github-bot changed target branch from main to gh-pr/3257/base 2026-12-03 15:45:43 +00:00
github manually merged commit 3bc1c333ef into gh-pr/3257/base 2026-12-03 15:46:14 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/ubiquitarianism--leonida!3257
No description provided.