nsExternalHelperAppService::ExternalProtocolHandlerExists (almost) always sets aHandlerExists to PR_TRUE, enabling gnomevfs protocols, patch by Karl Tomlinson <mozbugs@karlt.net, r+sr=biesi,dmose; a=roc

This commit is contained in:
dmose@mozilla.org 2007-07-27 11:31:13 -07:00
parent b8a667199d
commit 2b71ae690f
6 changed files with 23 additions and 6 deletions

View File

@ -240,7 +240,8 @@ nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme)
PRBool exists;
nsresult rv = OSProtocolHandlerExists(nsPromiseFlatCString(aScheme).get(),
&exists);
NS_ENSURE_SUCCESS(rv, nsnull);
if (NS_FAILED(rv) || !exists)
return nsnull;
nsMIMEInfoBeOS *handlerInfo =
new nsMIMEInfoBeOS(aScheme, nsMIMEInfoBase::eProtocolInfo);

View File

@ -323,7 +323,8 @@ nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme)
PRBool exists;
nsresult rv = OSProtocolHandlerExists(nsPromiseFlatCString(aScheme).get(),
&exists);
NS_ENSURE_SUCCESS(rv, nsnull);
if (NS_FAILED(rv) || !exists)
return nsnull;
nsMIMEInfoMac *handlerInfo =
new nsMIMEInfoMac(aScheme, nsMIMEInfoBase::eProtocolInfo);

View File

@ -584,8 +584,10 @@ NS_IMETHODIMP nsExternalProtocolHandler::NewURI(const nsACString &aSpec,
NS_IMETHODIMP nsExternalProtocolHandler::NewChannel(nsIURI *aURI, nsIChannel **_retval)
{
// only try to return a channel if we have a protocol handler for the url
// Only try to return a channel if we have a protocol handler for the url.
// nsOSHelperAppService::LoadUriInternal relies on this to check trustedness
// for some platforms at least. (win uses ::ShellExecute and unix uses
// gnome_url_show.)
PRBool haveExternalHandler = HaveExternalProtocolHandler(aURI);
if (haveExternalHandler)
{

View File

@ -242,6 +242,14 @@ nsGNOMERegistry::HandlerExists(const char *aProtocolScheme)
return PR_FALSE;
}
// XXX Check HandlerExists() before calling LoadURL.
//
// If there is not a registered handler for the protocol, gnome_url_show()
// falls back to using gnomevfs modules. See bug 389632. We don't want
// this fallback to happen as we are not sure of the safety of all gnomevfs
// modules and MIME-default applications. (gnomevfs should be handled in
// nsGnomeVFSProtocolHandler.)
/* static */ nsresult
nsGNOMERegistry::LoadURL(nsIURI *aURL)
{

View File

@ -1639,10 +1639,14 @@ nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme)
{
NS_ASSERTION(!aScheme.IsEmpty(), "No scheme was specified!");
// We must check that a registered handler exists so that gnome_url_show
// doesn't fallback to gnomevfs.
// See nsGNOMERegistry::LoadURL and bug 389632.
PRBool exists;
nsresult rv = OSProtocolHandlerExists(nsPromiseFlatCString(aScheme).get(),
&exists);
NS_ENSURE_SUCCESS(rv, nsnull);
if (NS_FAILED(rv) || !exists)
return nsnull;
nsMIMEInfoUnix *handlerInfo =
new nsMIMEInfoUnix(aScheme, nsMIMEInfoBase::eProtocolInfo);

View File

@ -561,7 +561,8 @@ nsOSHelperAppService::GetProtocolInfoFromOS(const nsACString &aScheme)
PRBool exists;
nsresult rv = OSProtocolHandlerExists(nsPromiseFlatCString(aScheme).get(),
&exists);
NS_ENSURE_SUCCESS(rv, nsnull);
if (NS_FAILED(rv) || !exists)
return nsnull;
nsMIMEInfoWin *handlerInfo =
new nsMIMEInfoWin(aScheme, nsMIMEInfoBase::eProtocolInfo);