From a1d0e21b0add05fc1a37a4abe2a3beeea6abc497 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Mon, 18 Mar 2024 17:53:18 +0000 Subject: [PATCH] shell32: PathResolve should remove trailing dot. --- dlls/shell32/shellpath.c | 24 ++++++++++++++++++------ dlls/shell32/tests/shellpath.c | 1 + 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c index 5d7f9d48ebd..e32bf5a50dc 100644 --- a/dlls/shell32/shellpath.c +++ b/dlls/shell32/shellpath.c @@ -694,10 +694,16 @@ static BOOL PathResolveA(char *path, const char **dirs, DWORD flags) if (flags & PRF_VERIFYEXISTS) { if (PathFindOnPathExA(path, dirs, dwWhich)) + { + if (!PathIsFileSpecA(path)) GetFullPathNameA(path, MAX_PATH, path, NULL); return TRUE; - if (!is_file_spec && PathFileExistsDefExtA(path, dwWhich)) - return TRUE; - if (!is_file_spec) GetFullPathNameA(path, MAX_PATH, path, NULL); + } + if (!is_file_spec) + { + GetFullPathNameA(path, MAX_PATH, path, NULL); + if (PathFileExistsDefExtA(path, dwWhich)) + return TRUE; + } SetLastError(ERROR_FILE_NOT_FOUND); return FALSE; } @@ -723,10 +729,16 @@ static BOOL PathResolveW(WCHAR *path, const WCHAR **dirs, DWORD flags) if (flags & PRF_VERIFYEXISTS) { if (PathFindOnPathExW(path, dirs, dwWhich)) + { + if (!PathIsFileSpecW(path)) GetFullPathNameW(path, MAX_PATH, path, NULL); return TRUE; - if (!is_file_spec && PathFileExistsDefExtW(path, dwWhich)) - return TRUE; - if (!is_file_spec) GetFullPathNameW(path, MAX_PATH, path, NULL); + } + if (!is_file_spec) + { + GetFullPathNameW(path, MAX_PATH, path, NULL); + if (PathFileExistsDefExtW(path, dwWhich)) + return TRUE; + } SetLastError(ERROR_FILE_NOT_FOUND); return FALSE; } diff --git a/dlls/shell32/tests/shellpath.c b/dlls/shell32/tests/shellpath.c index 75bcf6bf4fe..ef3d2a78256 100644 --- a/dlls/shell32/tests/shellpath.c +++ b/dlls/shell32/tests/shellpath.c @@ -2963,6 +2963,7 @@ static void test_PathResolve(void) /* PRF_VERIFYEXISTS */ { L"shellpath", PRF_VERIFYEXISTS, TRUE, testfile_lnk }, { L"shellpath.lnk", PRF_VERIFYEXISTS, TRUE, testfile_lnk }, + { L"shellpath.lnk.", PRF_VERIFYEXISTS, TRUE, testfile_lnk }, { L"C:\\shellpath", PRF_VERIFYEXISTS, FALSE, L"C:\\shellpath" }, /* common extensions are tried even if PRF_TRYPROGRAMEXTENSIONS isn't passed */ /* directories in dirs parameter are always searched first even if PRF_FIRSTDIRDEF isn't passed */