[Bug]: Driver CLI argument quoting breaks on trailing backslashes, embedded quotes and install paths with spaces

Aperta
#3,430 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@pcbeingused333 ci sta già lavorando.

Dal 9/11/2026.

  • #3449 di @pcbeingused333 — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
69/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp
Ambito
cli

Direzione di ricerca

Read src/Playwright/Program.cs and src/Playwright/Helpers/Driver.cs, especially the cited argument construction and process launch lines. Compare argument handling on the net8.0 and netstandard2.0 targets, then run the relevant driver CLI tests with trailing backslashes, embedded quotes, and an install path containing spaces. Done when arguments reach the CLI intact in each case.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

agent-triage
Version

1.64.0, and main at d79328b

Steps to reproduce

Program.cs#L95-L99 and Driver.cs#L139-L144:

getArgs(args.Length > 0 ? "\"" + string.Join("\" \"", args) + "\"" : null)
// getArgs(null) => cliEntrypoint, unquoted

For pwsh bin/Debug/net8.0/playwright.ps1 codegen --save-storage "C:\My Dir\" https://example.com the generated command line is:

"codegen" "--save-storage" "C:\My Dir\" "https://example.com"

Under Windows argv rules, \" escapes the quote, so the last two arguments merge.

Other cases:

  • Arguments that contain ", e.g. --grep 'say "hi"' or JSON passed to --viewport-size.
  • Running playwright.ps1 with no arguments when the project path contains a space (e.g. C:\Users\John Smith\...). cli.js is passed unquoted, so Node.js gets C:\Users\John.
Expected behavior

Arguments reach the Playwright CLI exactly as typed.

Actual behavior

Arguments are split or merged. With no arguments and a path containing spaces, Node.js fails with Cannot find module 'C:\Users\John'.

Additional context

Fix: on .NET Core / net8.0 use ProcessStartInfo.ArgumentList. On netstandard2.0, escape per the MSVCRT rules (double the backslashes before a quote, escape "), and always quote cli.js.

#3033 (multi-targeting) would make ArgumentList available.

Environment
- Operating System: Windows (also affects Linux/macOS for no-argument + spaces)
- CPU: any
- Browser: All
- .NET Version (TFM): any
- Other info: found by code review of main @ d79328b
Lingua principale
C#
Stelle
3k
Fork
307
Merge medio
1g 13h
PR unite (30g)
21

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/playwright-dotnet

Tutte le issue di microsoft/playwright-dotnet

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.