From: Mike Hommey <glandium@debian.org>
Date: Sat, 22 Nov 2008 09:35:23 +0100
Subject: Properly launch applications set in $HOME/.mailcap

Replaces the previous patch in a much simpler way.
---
 uriloader/exthandler/unix/nsMIMEInfoUnix.cpp |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
index 0b55ce9..6e1550f 100644
--- a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
+++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
@@ -73,6 +73,12 @@ nsMIMEInfoUnix::LoadUriInternal(nsIURI * aURI)
 NS_IMETHODIMP
 nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval)
 {
+  // if mDefaultApplication is set, it means the application has been set from
+  // either /etc/mailcap or ${HOME}/.mailcap, in which case we don't want to
+  // give the GNOME answer.
+  if (mDefaultApplication)
+    return nsMIMEInfoImpl::GetHasDefaultHandler(_retval);
+
   *_retval = PR_FALSE;
   nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
   if (vfs) {
@@ -93,13 +99,18 @@ nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval)
   }
 #endif
   
-  // If we didn't find a VFS handler, fallback.
-  return nsMIMEInfoImpl::GetHasDefaultHandler(_retval);
+  return NS_OK;
 }
 
 nsresult
 nsMIMEInfoUnix::LaunchDefaultWithFile(nsIFile *aFile)
 {
+  // if mDefaultApplication is set, it means the application has been set from
+  // either /etc/mailcap or ${HOME}/.mailcap, in which case we don't want to
+  // give the GNOME answer.
+  if (mDefaultApplication)
+    return nsMIMEInfoImpl::LaunchDefaultWithFile(aFile);
+
   nsCAutoString nativePath;
   aFile->GetNativePath(nativePath);
 
