From c5ad37baf0d4a4d14dd9bb07ca7a033ca0cdd018 Mon Sep 17 00:00:00 2001 From: Joachim Priesner Date: Wed, 3 Jun 2015 00:14:08 +0200 Subject: [PATCH] comdlg32: File dialog: Append multi-part extensions like .abc.def. --- dlls/comdlg32/filedlg.c | 5 +++-- dlls/comdlg32/tests/filedlg.c | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c index 28901082bde..1453396ccf7 100644 --- a/dlls/comdlg32/filedlg.c +++ b/dlls/comdlg32/filedlg.c @@ -2596,10 +2596,11 @@ BOOL FILEDLG95_OnOpen(HWND hwnd) filterSearchIndex[0] = '\0'; } + /* find the file extension by searching for the first dot in filterExt */ /* strip the * or anything else from the extension, "*.abc" becomes "abc" */ /* if the extension is invalid or contains a glob, ignore it */ - filterSearchIndex = PathFindExtensionW(filterExt); - if (*filterSearchIndex++ && !strchrW(filterSearchIndex, '*') && !strchrW(filterSearchIndex, '?')) + filterSearchIndex = strchrW(filterExt, '.'); + if (filterSearchIndex++ && !strchrW(filterSearchIndex, '*') && !strchrW(filterSearchIndex, '?')) { strcpyW(filterExt, filterSearchIndex); } diff --git a/dlls/comdlg32/tests/filedlg.c b/dlls/comdlg32/tests/filedlg.c index e3d9bc7aa44..49a430cb9fd 100644 --- a/dlls/comdlg32/tests/filedlg.c +++ b/dlls/comdlg32/tests/filedlg.c @@ -1130,6 +1130,11 @@ static void test_extension(void) for (i = 0; i < ARRAY_SIZE(defext_wildcard_filters); i++) { test_extension_helper(&ofn, defext_wildcard_filters[i], "deadbeef.xyz"); } + + /* Append valid extensions consisting of multiple parts */ + test_extension_helper(&ofn, "TestFilter (*.abc.def)\0*.abc.def\0", "deadbeef.abc.def"); + test_extension_helper(&ofn, "TestFilter (.abc.def)\0.abc.def\0", "deadbeef.abc.def"); + test_extension_helper(&ofn, "TestFilter (*.*.def)\0*.*.def\0", "deadbeef.xyz"); } #undef ARRAY_SIZE