play.ps1: gta6rt gets the folders as they were typed (PLAY-PS1-ARG-QUOTING) #3280

Merged
leonida/mandy
LouisRiverstone merged 1 commit from fix/play-ps1-arg-quoting into main 2026-12-03 15:16:47 +00:00

Pull request successfully merged and closed

LouisRiverstone commented 2026-12-03 02:12:25 +00:00

Claim: https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7361352199 (PLAY-PS1-ARG-QUOTING)

What and why

scripts/play.ps1 starts gta6rt.exe with Start-Process, which quotes nothing, so it quoted --run, --game-dir, --overlay and --trace by hand (""$Game""). gta6rt reads its arguments through wmain's argv (runtime/src/main.cpp), that is, by CommandLineToArgvW's rules, where a backslash in front of a quote escapes it. A folder typed with its last backslash (-Game D:\pkg\) therefore reached gta6rt as D:\pkg" --overlay ...: the folder and the arguments after it were merged. This is the same defect #3257 fixes in game-gate.ps1 and for the button-prompt tool.

What changed

  • scripts/play.ps1: ConvertTo-Argument quotes each value by those rules. The backslashes in front of a quote or of the closing quote are doubled (\z, not $). gta6rt makes both folders absolute and joins with /, so a trailing backslash it now receives intact is harmless.
  • tests/test_play_ps1_args.py compiles a stand-in gta6rt.exe with Add-Type that writes down its argv. It runs play.ps1 with folders that have spaces and are typed with their last backslash, and checks the eight arguments gta6rt receives.

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

  • Red/green by hand: with the .ps1 change reverted, the test fails (--game-dir arrives as ...\my game" --overlay ...). With it, the test passes.
  • python -I scripts/check_no_game_data.py on both files: exit 0. The .ps1 stays CRLF and ASCII; the test is LF and ASCII.

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 that gta6rt parses through wmain argv by the same rules as the stand-in, that a trailing backslash is harmless to its path handling, and that nothing else builds gta6rt's arguments this way. It found nothing blocking; I applied its suggestion to let the test's temporary folder clean up even if the compiled stand-in is still held open.

Claim: https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7361352199 (PLAY-PS1-ARG-QUOTING) ### What and why `scripts/play.ps1` starts `gta6rt.exe` with `Start-Process`, which quotes nothing, so it quoted `--run`, `--game-dir`, `--overlay` and `--trace` by hand (`"`"$Game`""`). gta6rt reads its arguments through `wmain`'s argv (`runtime/src/main.cpp`), that is, by `CommandLineToArgvW`'s rules, where a backslash in front of a quote escapes it. A folder typed with its last backslash (`-Game D:\pkg\`) therefore reached gta6rt as `D:\pkg" --overlay ...`: the folder and the arguments after it were merged. This is the same defect #3257 fixes in `game-gate.ps1` and for the button-prompt tool. ### What changed - `scripts/play.ps1`: `ConvertTo-Argument` quotes each value by those rules. The backslashes in front of a quote or of the closing quote are doubled (`\z`, not `$`). gta6rt makes both folders absolute and joins with `/`, so a trailing backslash it now receives intact is harmless. - `tests/test_play_ps1_args.py` compiles a stand-in `gta6rt.exe` with `Add-Type` that writes down its argv. It runs `play.ps1` with folders that have spaces and are typed with their last backslash, and checks the eight arguments gta6rt receives. ### Verification (Windows 11, Windows PowerShell 5.1, Python 3.11; no game files, no GPU needed) - Red/green by hand: with the `.ps1` change reverted, the test fails (`--game-dir` arrives as `...\my game" --overlay ...`). With it, the test passes. - `python -I scripts/check_no_game_data.py` on both files: exit 0. The `.ps1` stays CRLF and ASCII; the test is LF and ASCII. ### 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 that gta6rt parses through `wmain` argv by the same rules as the stand-in, that a trailing backslash is harmless to its path handling, and that nothing else builds gta6rt's arguments this way. It found nothing blocking; I applied its suggestion to let the test's temporary folder clean up even if the compiled stand-in is still held open.
merzleckeier reviewed 2026-12-03 02:27:16 +00:00
merzleckeier left a comment
No description provided.
Independently checked `fff47a33` merged onto `d15e048a`. I ran `play.ps1` with PowerShell 7.7.0 and captured the `Start-Process` argument list for seven synthetic folder layouts. I replayed the joined command line through `CommandLineToArgvW` and into a real Windows Python child process under Wine. Both decoders received the expected eight arguments in all seven cases. On `main`, both failed the four cases with a trailing Game or Overlay backslash, including multiple backslashes and a Unicode path. The plain, spaced-only, and default-overlay controls passed on both trees. The full Windows PowerShell test on this PR is complementary to this check of the actual serialized arguments. `git diff --check` was clean. AI-assisted with OpenAI Codex.
fiestorra commented 2026-12-03 02:29:22 +00:00

VERIFY-3280 — Windows nativo: el control quita el doblado de la barra final y el test muerde

Un commit, dos ficheros:

scripts/play.ps1            | 11 +++++--
tests/test_play_ps1_args.py | 75 ++++++++++++++++++++++++++++++++++

En el head (fff47a330):

pytest tests/test_play_ps1_args.py -q     1 passed (0.75 s)

Control (sintético): quité el segundo -replace, el que dobla las barras finales —

-  '"' + (($value -replace '(\\*)"', '$1$1\"') -replace '(\\+)\z', '$1$1') + '"'
+  '"' + (($value -replace '(\\*)"', '$1$1\"')) + '"'

y el test falla:

1 failed
  self.assertEqual(make.returncode, 0, make.stderr)
  self.assertEqual(res.returncode, 0, …)

Muerde, y muerde el caso que el test nombra: test_folders_ending_in_a_backslash_reach_the_runtime_whole — una carpeta D:\pkg\ que llega al runtime partida por la mitad, que es justo lo que el comentario del cambio dice: "backslashes in front of a quote or of the closing quote are doubled, else -Game D:\pkg\ would escape the closing quote and take the next argument with it."

Y por qué la función está escrita así, que es lo que quiero verificar en el fondo: no es «escapar comillas», es la regla de CommandLineToArgvW — las barras delante de una comilla o delante de la comilla de cierre se doblan, y sólo ésas. Doblar todas rompería C:\Games; no doblar la última se come el argumento siguiente. La expresión hace exactamente las dos cosas y el test comprueba las dos direcciones (args[:6] con las rutas enteras y len(args) == 8 sin argumentos de más).

Lo que no probé

  • El runtime recibiendo esos argumentos: el test corre play.ps1 y compara el argv que se construye, que es el punto, pero no el proceso hijo real de gta6rt.

Written with an AI assistant.

## VERIFY-3280 — Windows nativo: el control quita el doblado de la barra final y el test muerde **Un commit, dos ficheros**: ``` scripts/play.ps1 | 11 +++++-- tests/test_play_ps1_args.py | 75 ++++++++++++++++++++++++++++++++++ ``` **En el head (`fff47a330`)**: ``` pytest tests/test_play_ps1_args.py -q 1 passed (0.75 s) ``` **Control (sintético)**: **quité el segundo `-replace`, el que dobla las barras finales** — ```powershell - '"' + (($value -replace '(\\*)"', '$1$1\"') -replace '(\\+)\z', '$1$1') + '"' + '"' + (($value -replace '(\\*)"', '$1$1\"')) + '"' ``` **y el test falla**: ``` 1 failed self.assertEqual(make.returncode, 0, make.stderr) self.assertEqual(res.returncode, 0, …) ``` **Muerde, y muerde el caso que el test nombra**: **`test_folders_ending_in_a_backslash_reach_the_runtime_whole`** — **una carpeta `D:\pkg\` que llega al runtime partida por la mitad**, **que es justo lo que el comentario del cambio dice**: *"backslashes in front of a quote or of the closing quote are doubled, else `-Game D:\pkg\` would escape the closing quote and take the next argument with it."* **Y por qué la función está escrita así, que es lo que quiero verificar en el fondo**: **no es «escapar comillas», es la regla de `CommandLineToArgvW`** — **las barras *delante de una comilla* o *delante de la comilla de cierre* se doblan, y sólo ésas.** **Doblar todas rompería `C:\Games`; no doblar la última se come el argumento siguiente.** **La expresión hace exactamente las dos cosas y el test comprueba las dos direcciones** (`args[:6]` con las rutas enteras y `len(args) == 8` sin argumentos de más). ## Lo que no probé - **El runtime recibiendo esos argumentos**: **el test corre `play.ps1` y compara el `argv` que *se construye***, **que es el punto, pero no el proceso hijo real de gta6rt.** Written with an AI assistant.
lixonik commented 2026-12-03 06:29:30 +00:00

Windows native verification (red -> green) -- PASS on head fff47a330 (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_play_ps1_args.py -v -> Ran 1 test in 0.530s / OK
  • Red (reverted scripts/play.ps1 to main d9b618f10, keeping the PR's tests):
    • tests/test_play_ps1_args.py -> Ran 1 test in 0.520s / FAILED (failures=1) (exit 1)

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

**Windows native verification (`red -> green`) -- PASS** on head `fff47a330` (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_play_ps1_args.py -v` -> **Ran 1 test in 0.530s / OK** - **Red** (reverted `scripts/play.ps1` to `main` `d9b618f10`, keeping the PR's tests): - `tests/test_play_ps1_args.py` -> **Ran 1 test in 0.520s / FAILED (failures=1)** (exit `1`) AI-assisted: yes (Antigravity -- Gemini 4 Neon).
TurboTheTurtle commented 2026-12-03 07:09:37 +00:00

tested: the new test passes on this machine, and the folder with a space in it is exactly the case here. Machine: Windows 11, NVIDIA GeForce RTX 5080, driver 621.47, hardware-accelerated GPU scheduling on, page file 49,152 MB, tree at e5c777734 (three d3d12/README.md commits on main d9b618f10).

python -I tests/test_play_ps1_args.py -> Ran 1 test in 0.749s, OK, rc 0. node --test tests/test_*.cjs -> 113 tests, 0 fail. Head fff47a330.

Every path on this box has a space in it, so the quoting is not a corner case here: the game is at F:\GTA 6\GTA6.Xbox.v1.0.2.1-CYBERLEEK and the data folder at F:\GTA 6\Leonida, and the same folders go to play-d3d12.ps1 for the D3D12 layer, where they already arrive whole. The Vulkan runtime is not built on this machine (runtime\build-vk\RelWithDebInfo\gta6rt.exe absent), so the script's own test is the evidence, and the argument list is built at scripts/play.ps1:50 with the CommandLineToArgvW quoting the comment names.

tested: the new test passes on this machine, and the folder with a space in it is exactly the case here. Machine: Windows 11, NVIDIA GeForce RTX 5080, driver 621.47, hardware-accelerated GPU scheduling on, page file 49,152 MB, tree at `e5c777734` (three `d3d12/README.md` commits on main `d9b618f10`). `python -I tests/test_play_ps1_args.py` -> `Ran 1 test in 0.749s`, `OK`, rc 0. `node --test tests/test_*.cjs` -> 113 tests, 0 fail. Head `fff47a330`. Every path on this box has a space in it, so the quoting is not a corner case here: the game is at `F:\GTA 6\GTA6.Xbox.v1.0.2.1-CYBERLEEK` and the data folder at `F:\GTA 6\Leonida`, and the same folders go to `play-d3d12.ps1` for the D3D12 layer, where they already arrive whole. The Vulkan runtime is not built on this machine (`runtime\build-vk\RelWithDebInfo\gta6rt.exe` absent), so the script's own test is the evidence, and the argument list is built at `scripts/play.ps1:50` with the `CommandLineToArgvW` quoting the comment names.
Sign in to join this conversation.
No description provided.