shell32: Use SearchPathW() for %l/%L in SHELL_ArgifyW().

This commit is contained in:
Paul Gofman 2023-10-25 14:23:20 -06:00 committed by Alexandre Julliard
parent 2fcf40a6e1
commit 68fd74e7f9
2 changed files with 35 additions and 5 deletions

View file

@ -77,7 +77,7 @@ static BOOL SHELL_ArgifyW(WCHAR* out, int len, const WCHAR* fmt, const WCHAR* lp
BOOL found_p1 = FALSE;
PWSTR res = out;
PCWSTR cmd;
DWORD used = 0;
DWORD size, used = 0;
TRACE("%p, %d, %s, %s, %p, %p\n", out, len, debugstr_w(fmt),
debugstr_w(lpFile), pidl, args);
@ -164,11 +164,16 @@ static BOOL SHELL_ArgifyW(WCHAR* out, int len, const WCHAR* fmt, const WCHAR* lp
case 'l':
case 'L':
if (lpFile) {
used += lstrlenW(lpFile);
if ((size = SearchPathW(NULL, lpFile, L".exe", ARRAY_SIZE(xlpFile), xlpFile, NULL)
&& size <= ARRAY_SIZE(xlpFile)))
cmd = xlpFile;
else
cmd = lpFile;
used += lstrlenW(cmd);
if (used < len)
{
lstrcpyW(res, lpFile);
res += lstrlenW(lpFile);
lstrcpyW(res, cmd);
res += lstrlenW(cmd);
}
}
found_p1 = TRUE;

View file

@ -1624,7 +1624,7 @@ static void test_argify(void)
static void test_filename(void)
{
char filename[MAX_PATH + 20];
char filename[MAX_PATH + 20], curdir[MAX_PATH];
const filename_tests_t* test;
char* c;
INT_PTR rc;
@ -1635,6 +1635,31 @@ static void test_filename(void)
return;
}
GetCurrentDirectoryA(sizeof(curdir), curdir);
SetCurrentDirectoryA(tmpdir);
rc=shell_execute("QuotedLowerL", "simple.shlexec", NULL, NULL);
if (rc > 32)
rc=33;
okShell(rc == 33, "failed: rc=%Id err=%lu\n", rc, GetLastError());
okChildInt("argcA", 5);
okChildString("argvA3", "QuotedLowerL");
strcpy(filename, tmpdir);
strcat(filename, "\\simple.shlexec");
okChildPath("argvA4", filename);
rc=shell_execute("QuotedUpperL", "simple.shlexec", NULL, NULL);
if (rc > 32)
rc=33;
okShell(rc == 33, "failed: rc=%Id err=%lu\n", rc, GetLastError());
okChildInt("argcA", 5);
okChildString("argvA3", "QuotedUpperL");
strcpy(filename, tmpdir);
strcat(filename, "\\simple.shlexec");
okChildPath("argvA4", filename);
SetCurrentDirectoryA(curdir);
test=filename_tests;
while (test->basename)
{