Fix garbled output and false "not runnable" in Windows version probe

The version probe ran `cmd /C "\"{path}\" --version"` on Windows. Rust's
own arg quoting plus the manual quotes produced nested quotes that cmd
(without /S) misparsed, so it reported even working tools as an
unrecognized command -> non-zero exit -> shown as "installed but not
runnable". cmd's error is emitted in the OEM code page (e.g. GBK on
zh-CN) and was decoded as UTF-8, turning it into mojibake.

- Add decode_command_output: try strict UTF-8, then OEM (GetOEMCP), then
  ANSI (GetACP) code page via MultiByteToWideChar; route all command
  output decoding through it (probes, lifecycle output, osascript,
  terminal launchers).
- Add run_windows_tool_version_command: run .exe directly (no cmd);
  invoke .cmd/.bat via `cmd /D /S /C call <quoted> --version` with
  raw_arg to bypass Rust's quoting and keep deterministic quote handling.
- Add windows-sys Win32_Globalization dependency.
This commit is contained in:
Jason
2026-05-30 17:46:35 +08:00
parent 2683af57cb
commit ee69c83687
3 changed files with 135 additions and 35 deletions
+1
View File
@@ -798,6 +798,7 @@ dependencies = [
"uuid",
"webkit2gtk",
"webpki-roots 0.26.11",
"windows-sys 0.61.2",
"winreg 0.52.0",
"zip 2.4.2",
]