msiexec: Fix escaping quoted arguments passed from Shell.

Properties with spaces passed to msiexec from shells like Bash may result in re-escaping the string. This results in wrong new quote position and so in MSI error ERROR_INVALID_COMMAND_LINE. This patch moves the quote back to its legal position.

Step-by-step behavior after fixes in commit 14b718b69bb8d (linked with Wine bug https://bugs.winehq.org/show_bug.cgi?id=57024):

  1. Shell input:

    wine msiexec /i some.msi INSTALLDIR="C:\Path with spaces\data"

  2. Shell args parser may remove double quote escaping:

    args[3] == "some.msi" args[4] == "INSTALLDIR=C:\Path with spaces\data"

  3. GetCommandLineW() returns string with quote moved to the start:

    "msiexec ... some.msi "INSTALLDIR=C:\Path with spaces\data""

  4. Then MSI parser truncates beginning of the string up to character '=', leading to unbalanced quotes in result value:

    C:\Path with spaces\data"

  5. MSI fails with error ERROR_INVALID_COMMAND_LINE (1639).

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57024

Tests in bug 57024 are fine to reproduce the behavior, but note that system() and execvp() function passes their input on without extra parsing (without item 2 in the fail trace algorithm above). An example of such test:

execlp("msiexec", "msiexec", "/i", msi_path, "/qn", "\"MY_PROPERTY=foo bar\"", NULL);

Merge request reports

Loading