Commit 5cb4c553 authored by Wolfram Sang's avatar Wolfram Sang Committed by Alexandre Julliard

comdlg32: Filedlg should not add extension if it contains a glob.

parent 08f13cbd
...@@ -2491,8 +2491,8 @@ BOOL FILEDLG95_OnOpen(HWND hwnd) ...@@ -2491,8 +2491,8 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
else if ( fodInfos->defext ) /* attach the default file extension*/ else if ( fodInfos->defext ) /* attach the default file extension*/
filterExt = fodInfos->defext; filterExt = fodInfos->defext;
/* If extension is .*, ignore it */ /* If extension contains a glob, ignore it */
if (filterExt[0] != '*') if ( filterExt && !strchrW(filterExt, '*') && !strchrW(filterExt, '?') )
{ {
/* Attach the dot*/ /* Attach the dot*/
lstrcatW(lpstrPathAndFile, szwDot); lstrcatW(lpstrPathAndFile, szwDot);
......
...@@ -1052,6 +1052,15 @@ static UINT_PTR WINAPI test_extension_wndproc(HWND dlg, UINT msg, WPARAM wParam, ...@@ -1052,6 +1052,15 @@ static UINT_PTR WINAPI test_extension_wndproc(HWND dlg, UINT msg, WPARAM wParam,
return FALSE; return FALSE;
} }
static const char *defext_filters[] = {
"TestFilter (*.pt*)\0*.pt*\0",
"TestFilter (*.ab?)\0*.ab?\0",
"TestFilter (*.*)\0*.*\0",
NULL /* is a test, not an endmark! */
};
#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
static void test_extension(void) static void test_extension(void)
{ {
OPENFILENAME ofn = { sizeof(OPENFILENAME)}; OPENFILENAME ofn = { sizeof(OPENFILENAME)};
...@@ -1059,11 +1068,12 @@ static void test_extension(void) ...@@ -1059,11 +1068,12 @@ static void test_extension(void)
char curdir[MAX_PATH]; char curdir[MAX_PATH];
char *filename_ptr; char *filename_ptr;
const char *test_file_name = "deadbeef"; const char *test_file_name = "deadbeef";
const char **cur_filter;
DWORD ret; DWORD ret;
BOOL cdret; BOOL boolret;
cdret = GetCurrentDirectoryA(sizeof(curdir), curdir); boolret = GetCurrentDirectoryA(sizeof(curdir), curdir);
ok(cdret, "Failed to get current dir err %d\n", GetLastError()); ok(boolret, "Failed to get current dir err %d\n", GetLastError());
/* Ignore .* extension */ /* Ignore .* extension */
ofn.lStructSize = sizeof(ofn); ofn.lStructSize = sizeof(ofn);
...@@ -1075,17 +1085,23 @@ static void test_extension(void) ...@@ -1075,17 +1085,23 @@ static void test_extension(void)
ofn.lpstrInitialDir = curdir; ofn.lpstrInitialDir = curdir;
ofn.lpfnHook = test_extension_wndproc; ofn.lpfnHook = test_extension_wndproc;
ofn.nFileExtension = 0; ofn.nFileExtension = 0;
ofn.lpstrFilter = "All Files (*.*)\0*.*\0";
strcpy(filename, test_file_name); for (cur_filter = defext_filters; cur_filter < defext_filters + ARRAY_SIZE(defext_filters); cur_filter++) {
ofn.lpstrFilter = *cur_filter;
ret = GetSaveFileNameA(&ofn); strcpy(filename, test_file_name);
filename_ptr = ofn.lpstrFile + strlen( ofn.lpstrFile ) - strlen( test_file_name ); boolret = GetSaveFileNameA(&ofn);
ok(1 == ret, "expected 1, got %d\n", ret); ok(boolret, "expected true\n");
ok(strlen(ofn.lpstrFile) >= strlen(test_file_name), "Filename %s is too short\n", ofn.lpstrFile ); ret = CommDlgExtendedError();
ok( strcmp(filename_ptr, test_file_name) == 0, ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
"Filename is %s, expected %s\n", filename_ptr, test_file_name ); filename_ptr = ofn.lpstrFile + strlen( ofn.lpstrFile ) - strlen( test_file_name );
ok( strlen(ofn.lpstrFile) >= strlen(test_file_name), "Filename %s is too short\n", ofn.lpstrFile );
ok( strcmp(filename_ptr, test_file_name) == 0,
"Filename is %s, expected %s\n", filename_ptr, test_file_name );
}
} }
#undef ARRAY_SIZE
START_TEST(filedlg) START_TEST(filedlg)
{ {
test_DialogCancel(); test_DialogCancel();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment