From: YeshunYe <yeyeshun@uniontech.com> The `cmdline_to_argv` function previously had a bug in handling backslashes preceding double quotes, particularly regarding the escaping rules. When processing a case like `"\"c:\windows\\""`, the flawed logic incorrectly consumed the quote character, leading to an error in parsing the number of arguments. Signed-off-by: YeshunYe <yeyeshun@uniontech.com> --- dlls/msvcrt/data.c | 6 +++--- programs/cmd/tests/test_builtins.bat.exp | 2 +- programs/cmd/tests/test_builtins.cmd.exp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dlls/msvcrt/data.c b/dlls/msvcrt/data.c index 6e764e52eae..6166f7540b0 100644 --- a/dlls/msvcrt/data.c +++ b/dlls/msvcrt/data.c @@ -119,8 +119,8 @@ static WCHAR **cmdline_to_argv( const WCHAR *src, int *ret_argc ) */ dst -= bcount / 2; src++; - if (in_quotes && *src == '"') *dst++ = *src++; - else in_quotes = !in_quotes; + in_quotes = !in_quotes; + if (bcount) bcount--; } else { @@ -129,8 +129,8 @@ static WCHAR **cmdline_to_argv( const WCHAR *src, int *ret_argc ) */ dst -= bcount / 2 + 1; *dst++ = *src++; + bcount = 0; } - bcount = 0; } else /* a regular character */ { diff --git a/programs/cmd/tests/test_builtins.bat.exp b/programs/cmd/tests/test_builtins.bat.exp index 20dda0c9ca7..383c237b684 100644 --- a/programs/cmd/tests/test_builtins.bat.exp +++ b/programs/cmd/tests/test_builtins.bat.exp @@ -63,7 +63,7 @@ foo@space@ SUCCESS 1024 @todo_wine@SUCCESS 666 0 -@todo_wine@0 +0 --- success/failure for TYPE command FAILURE 1 SUCCESS 0 diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index f5358709f83..c88dee42c16 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -582,7 +582,7 @@ foo@space@ SUCCESS 1024 @todo_wine@SUCCESS 666 0 -@todo_wine@0 +0 --- success/failure for TYPE command FAILURE 1 SUCCESS 0 -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9996