diff --git a/xpfe/components/xremote/src/XRemoteService.cpp b/xpfe/components/xremote/src/XRemoteService.cpp index 60e67a63f0c..857818f0c6c 100644 --- a/xpfe/components/xremote/src/XRemoteService.cpp +++ b/xpfe/components/xremote/src/XRemoteService.cpp @@ -657,23 +657,39 @@ XRemoteService::MayOpenURL(const nsCString &aURL) // by default, we assume nothing can be loaded. PRBool allowURL= PR_FALSE; - nsCOMPtr ios = do_GetIOService(); - if (ios) { + nsCOMPtr extProtService = + do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID); + if (extProtService) { nsCAutoString scheme; - ios->ExtractScheme(aURL, scheme); - if (!scheme.IsEmpty()) { - nsCOMPtr extProtService = - do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID); - if (extProtService) { - // if the given URL scheme corresponds to an exposed protocol, then we - // can try to load it. otherwise, we must not. - PRBool isExposed; - nsresult rv = extProtService->IsExposedProtocol(scheme.get(), &isExposed); - if (NS_SUCCEEDED(rv) && isExposed) - allowURL = PR_TRUE; // ok, we can load this URL. + + // empty URLs will be treated as about:blank by OpenURL + if (aURL.IsEmpty()) { + scheme = NS_LITERAL_CSTRING("about"); + } + else { + nsCOMPtr ios = do_GetIOService(); + if (ios) { + ios->ExtractScheme(aURL, scheme); + if (scheme.IsEmpty()) { + // could not parse out a scheme. perhaps this is a file path. + nsCOMPtr file; + NS_NewNativeLocalFile(aURL, PR_FALSE, getter_AddRefs(file)); + if (file) + scheme = NS_LITERAL_CSTRING("file"); + } } } + + if (!scheme.IsEmpty()) { + // if the given URL scheme corresponds to an exposed protocol, then we + // can try to load it. otherwise, we must not. + PRBool isExposed; + nsresult rv = extProtService->IsExposedProtocol(scheme.get(), &isExposed); + if (NS_SUCCEEDED(rv) && isExposed) + allowURL = PR_TRUE; // ok, we can load this URL. + } } + return allowURL; }