Module: wine Branch: stable Commit: 380d97406f86fa3aa601aced3e53c60eae66193d URL: https://source.winehq.org/git/wine.git/?a=commit;h=380d97406f86fa3aa601aced3...
Author: Vijay Kiran Kamuju infyquest@gmail.com Date: Fri Feb 22 14:25:59 2019 +0100
user32: Add DlgDirList wildcard checks.
Based on a patch from Christian Lupien.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=8226 Signed-off-by: Vijay Kiran Kamuju infyquest@gmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org (cherry picked from commit 7a6b00dc25880bd7e8515551b7c3fa7917776eaf) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
dlls/comctl32/tests/listbox.c | 6 +++--- dlls/user32/dialog.c | 9 ++++++++- dlls/user32/tests/listbox.c | 6 +++--- 3 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/dlls/comctl32/tests/listbox.c b/dlls/comctl32/tests/listbox.c index e789483..76948fd 100644 --- a/dlls/comctl32/tests/listbox.c +++ b/dlls/comctl32/tests/listbox.c @@ -1812,7 +1812,7 @@ static void test_listbox_dlgdir(void) strcpy(pathBuffer, "C:\"); res = DlgDirListA(hWnd, pathBuffer, ID_TEST_LISTBOX, 0, DDL_DIRECTORY | DDL_EXCLUSIVE); ok(res, "DlgDirList failed to list C:\ folders\n"); - todo_wine ok(!strcmp(pathBuffer, "*"), "DlgDirList set the invalid path spec '%s', expected '*'\n", pathBuffer); + ok(!strcmp(pathBuffer, "*"), "DlgDirList set the invalid path spec '%s', expected '*'\n", pathBuffer);
strcpy(pathBuffer, "C:\*"); res = DlgDirListA(hWnd, pathBuffer, ID_TEST_LISTBOX, 0, DDL_DIRECTORY | DDL_EXCLUSIVE); @@ -1823,8 +1823,8 @@ static void test_listbox_dlgdir(void) SetLastError(0xdeadbeef); strcpy(pathBuffer, "C:\INVALID$$DIR"); res = DlgDirListA(hWnd, pathBuffer, ID_TEST_LISTBOX, 0, DDL_DIRECTORY | DDL_EXCLUSIVE); - todo_wine ok(!res, "DlgDirList should have failed with 0 but %d was returned\n", res); - todo_wine ok(GetLastError() == ERROR_NO_WILDCARD_CHARACTERS, + ok(!res, "DlgDirList should have failed with 0 but %d was returned\n", res); + ok(GetLastError() == ERROR_NO_WILDCARD_CHARACTERS, "GetLastError should return 0x589, got 0x%X\n",GetLastError());
DestroyWindow(hWnd); diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c index deaeb84..88c2930 100644 --- a/dlls/user32/dialog.c +++ b/dlls/user32/dialog.c @@ -1821,6 +1821,7 @@ static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox, HWND hwnd; LPWSTR orig_spec = spec; WCHAR any[] = {'*','.','*',0}; + WCHAR star[] = {'*',0};
#define SENDMSG(msg,wparam,lparam) \ ((attrib & DDL_POSTMSGS) ? PostMessageW( hwnd, msg, wparam, lparam ) \ @@ -1829,10 +1830,16 @@ static INT DIALOG_DlgDirListW( HWND hDlg, LPWSTR spec, INT idLBox, TRACE("%p %s %d %d %04x\n", hDlg, debugstr_w(spec), idLBox, idStatic, attrib );
/* If the path exists and is a directory, chdir to it */ - if (!spec || !spec[0] || SetCurrentDirectoryW( spec )) spec = any; + if (!spec || !spec[0] || SetCurrentDirectoryW( spec )) spec = star; else { WCHAR *p, *p2; + + if (!strchrW(spec, '*') && !strchrW(spec, '?')) + { + SetLastError(ERROR_NO_WILDCARD_CHARACTERS); + return FALSE; + } p = spec; if ((p2 = strchrW( p, ':' ))) p = p2 + 1; if ((p2 = strrchrW( p, '\' ))) p = p2; diff --git a/dlls/user32/tests/listbox.c b/dlls/user32/tests/listbox.c index b87acd7..a3d3ae6 100644 --- a/dlls/user32/tests/listbox.c +++ b/dlls/user32/tests/listbox.c @@ -1707,7 +1707,7 @@ static void test_listbox_dlgdir(void) strcpy(pathBuffer, "C:\"); res = DlgDirListA(hWnd, pathBuffer, ID_TEST_LISTBOX, 0, DDL_DIRECTORY | DDL_EXCLUSIVE); ok(res || broken(!res) /* NT4/W2K */, "DlgDirList failed to list C:\ folders\n"); - todo_wine ok(!strcmp(pathBuffer, "*") || broken(!res) /* NT4/W2K */, + ok(!strcmp(pathBuffer, "*") || broken(!res) /* NT4/W2K */, "DlgDirList set the invalid path spec '%s', expected '*'\n", pathBuffer);
strcpy(pathBuffer, "C:\*"); @@ -1720,8 +1720,8 @@ static void test_listbox_dlgdir(void) SetLastError(0xdeadbeef); strcpy(pathBuffer, "C:\INVALID$$DIR"); res = DlgDirListA(hWnd, pathBuffer, ID_TEST_LISTBOX, 0, DDL_DIRECTORY | DDL_EXCLUSIVE); - todo_wine ok(!res, "DlgDirList should have failed with 0 but %d was returned\n", res); - todo_wine ok(GetLastError() == ERROR_NO_WILDCARD_CHARACTERS, + ok(!res, "DlgDirList should have failed with 0 but %d was returned\n", res); + ok(GetLastError() == ERROR_NO_WILDCARD_CHARACTERS, "GetLastError should return 0x589, got 0x%X\n",GetLastError());
DestroyWindow(hWnd);