On Tue, 15 Mar 2022 at 21:07:12 +0100, Carsten Schoenert wrote: > Unfortunately I'm getting the following error while built Thunderbird > with your patch.
Sorry, looks like I previously attached an outdated version of the patch. This one should be better? smcv
From: Simon McVittie <s...@debian.org> Date: Wed, 9 Mar 2022 11:22:42 +0000 Subject: Bug 1494436 - Unset MOZ_APP_LAUNCHER for external MIME handlers If Thunderbird sets this in its startup script (as it does in Debian and Fedora), Firefox does not set this in its startup script (it doesn't in Debian), and Firefox is the handler for clicking a link in Thunderbird, then Firefox will think it is part of Thunderbird and offer to make Thunderbird (not Firefox!) the default browser. If the user accepts this, it will break the ability to open normal HTTP links and HTML files from other applications. The same would be true for any other pair of Mozilla-based applications. To avoid this, unset MOZ_APP_LAUNCHER for the Firefox child process. Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1494436 Bug-Debian: https://bugs.debian.org/948691 --- toolkit/system/gnome/nsGIOService.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/toolkit/system/gnome/nsGIOService.cpp b/toolkit/system/gnome/nsGIOService.cpp index 3f0a53b..93b695f 100644 --- a/toolkit/system/gnome/nsGIOService.cpp +++ b/toolkit/system/gnome/nsGIOService.cpp @@ -23,6 +23,17 @@ using namespace mozilla; +static GAppLaunchContext* GetAppLaunchContext() { + GAppLaunchContext* context = g_app_launch_context_new(); + // Unset this before launching third-party MIME handlers. Otherwise, + // if Thunderbird sets this in its startup script (as it does in Debian + // and Fedora), and Firefox does not set this in its startup script + // (it doesn't in Debian), then Firefox will think it is part of + // Thunderbird and try to make Thunderbird the default browser. + g_app_launch_context_unsetenv(context, "MOZ_APP_LAUNCHER"); + return context; +} + // s. a. the code gtk_should_use_portal() uses to detect if in flatpak env // https://gitlab.gnome.org/GNOME/gtk/-/blob/4300a5c609306ce77cbc8a3580c19201dccd8d13/gdk/gdk.c#L472 static bool GetFlatpakPortalEnv() { @@ -240,7 +251,9 @@ nsGIOMimeApp::LaunchWithURI(nsIURI* aUri, uris.data = const_cast<char*>(spec.get()); GError* error = nullptr; - gboolean result = g_app_info_launch_uris(mApp, &uris, nullptr, &error); + GAppLaunchContext* context = GetAppLaunchContext(); + gboolean result = g_app_info_launch_uris(mApp, &uris, context, &error); + g_object_unref(context); if (!result) { g_warning("Cannot launch application: %s", error->message); @@ -546,7 +559,10 @@ nsGIOService::ShowURI(nsIURI* aURI) { nsresult rv = aURI->GetSpec(spec); NS_ENSURE_SUCCESS(rv, rv); GError* error = nullptr; - if (!g_app_info_launch_default_for_uri(spec.get(), nullptr, &error)) { + GAppLaunchContext* context = GetAppLaunchContext(); + g_app_info_launch_default_for_uri(spec.get(), context, &error); + g_object_unref(context); + if (error) { g_warning("Could not launch default application for URI: %s", error->message); g_error_free(error); @@ -562,7 +578,9 @@ nsGIOService::ShowURIForInput(const nsACString& aUri) { nsresult rv = NS_ERROR_FAILURE; GError* error = nullptr; - g_app_info_launch_default_for_uri(spec, nullptr, &error); + GAppLaunchContext* context = GetAppLaunchContext(); + g_app_info_launch_default_for_uri(spec, context, &error); + g_object_unref(context); if (error) { g_warning("Cannot launch default application: %s", error->message); g_error_free(error);