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

Merged
LouisRiverstone merged 1 commit from upstream-pr/3257 into main 2026-12-03 15:39:11 +00:00
LouisRiverstone commented 2026-12-02 22:50:09 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by LouisRiverstone on 2026-12-02T22:50:09Z.


Claim: https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7361113895 (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.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5616114341 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3257). Originally posted by [LouisRiverstone](https://github.com/LouisRiverstone) on 2026-12-02T22:50:09Z. --- Claim: https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7361113895 (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.
merzleckeier commented 2026-12-02 22:53:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T22:53:15Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6160471760 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3257#pullrequestreview-6160471760). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-02T22:53:15Z. **Review:** COMMENTED --- 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`.
fiestorra commented 2026-12-03 00:08:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-03T00:08:28Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7362842221 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3257#issuecomment-7362842221). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-03T00:08:28Z. --- ## 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.
lixonik commented 2026-12-03 06:31:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-03T06:31:31Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7369932348 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3257#issuecomment-7369932348). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-03T06:31:31Z. --- **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).
MoonEyes commented 2026-12-03 15:26:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T15:26:55Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7383158345 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3257#issuecomment-7383158345). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-03T15:26:55Z. --- 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.
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
ProjectLeonida/mandy!3257
No description provided.