Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=41275
A version of this patch has been in Wine Staging since March 2020.
-- v4: winemenubuilder: Skip desktop integration for certain associations.
From: Alex Henrie alexhenrie24@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=41275 --- programs/winemenubuilder/winemenubuilder.c | 63 ++++++++++++++++++++-- 1 file changed, 58 insertions(+), 5 deletions(-)
diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c index 1579ca8dafa..a2e32e56103 100644 --- a/programs/winemenubuilder/winemenubuilder.c +++ b/programs/winemenubuilder/winemenubuilder.c @@ -1974,6 +1974,55 @@ static BOOL is_extension_banned(LPCWSTR extension) return FALSE; }
+static BOOL on_exclude_list(const WCHAR *command) +{ + static const WCHAR default_exclude_list[] = L"ieframe.dll\0iexplore.exe\0notepad.exe\0" + L"winebrowser.exe\0wordpad.exe\0"; + WCHAR *exclude_list = (WCHAR *)default_exclude_list; + const WCHAR *pattern; + HKEY key; + DWORD size; + LSTATUS status; + BOOL found = FALSE; + + if ((key = open_associations_reg_key())) + { + status = RegGetValueW(key, NULL, L"Exclude", RRF_RT_REG_MULTI_SZ, NULL, NULL, &size); + if (status == ERROR_SUCCESS) + { + exclude_list = xmalloc(size); + status = RegGetValueW(key, NULL, L"Exclude", RRF_RT_REG_MULTI_SZ, NULL, exclude_list, &size); + if (status != ERROR_SUCCESS) + { + heap_free(exclude_list); + exclude_list = (WCHAR *)default_exclude_list; + } + } + else if (status == ERROR_FILE_NOT_FOUND) + { + /* If the exclude list does not exist in the registry, create it with the default value to + * make it easier for the user to modify if desired */ + RegSetValueExW(key, L"Exclude", 0, REG_MULTI_SZ, (BYTE *)default_exclude_list, + sizeof(default_exclude_list)); + } + RegCloseKey(key); + } + + for (pattern = exclude_list; *pattern; pattern = wcschr(pattern, 0) + 1) + { + if (wcsstr(command, pattern)) + { + found = TRUE; + break; + } + } + + if (exclude_list != default_exclude_list) + heap_free(exclude_list); + + return found; +} + static WCHAR *get_special_mime_type(LPCWSTR extension) { if (!wcsicmp(extension, L".lnk")) @@ -2054,6 +2103,15 @@ static BOOL generate_associations(const WCHAR *packages_dir, const WCHAR *applic WCHAR *mimeProgId = NULL; struct rb_string_entry *entry;
+ commandW = assoc_query(ASSOCSTR_COMMAND, extensionW, L"open"); + if (commandW == NULL) + /* no command => no application is associated */ + goto end; + + if (on_exclude_list(commandW)) + /* command is on the exclude list => desktop integration is not desirable */ + goto end; + wcslwr(extensionW); friendlyDocNameW = assoc_query(ASSOCSTR_FRIENDLYDOCNAME, extensionW, NULL);
@@ -2093,11 +2151,6 @@ static BOOL generate_associations(const WCHAR *packages_dir, const WCHAR *applic hasChanged = TRUE; }
- commandW = assoc_query(ASSOCSTR_COMMAND, extensionW, L"open"); - if (commandW == NULL) - /* no command => no application is associated */ - goto end; - executableW = assoc_query(ASSOCSTR_EXECUTABLE, extensionW, L"open"); if (executableW) openWithIcon = compute_native_identifier(0, executableW, NULL);
On Tue Mar 14 05:31:25 2023 +0000, Alex Henrie wrote:
changed this line in [version 4 of the diff](/wine/wine/-/merge_requests/1009/diffs?diff_id=36898&start_sha=451867a9e1dce92ee6409d8ede3bc1b0ea16a676#dcea097491aea5c674c4bd70c05f7ab7b0278e18_329_324)
I have pushed a new patch that stores the exclusion list in a single REG_MULTI_SZ value, which seems more elegant than creating a separate registry value for each pattern to exclude.
The new patch has winemenubuilder create the registry value if it does not exist. It's not strictly necessary to create it at all, but it will make life easier for users who just want to add their program to the exclude list, because otherwise they would have to look up the default list to know how to customize it.
The new patch has winemenubuilder create the registry value if it does not exist.
Again, we should not be creating config keys, this will prevent changing the defaults or removing the key.