Bug 1527717 - Check the registry for 'URL Protocol' when checking if a protocol handler exists. r=jmathies a=lizzard
authorRobert Strong <robert.bugzilla@gmail.com>
Fri, 15 Feb 2019 00:36:26 +0000
changeset 516001 bb9e3868a7bf0e1eeca0209d9943732ffb855958
parent 516000 971f22f74c696c4894ff891494522b76a94c1d76
child 516002 4c4ff2febd8386343f67a62f08efab02f78e03f0
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmathies, lizzard
bugs1527717
milestone66.0
Bug 1527717 - Check the registry for 'URL Protocol' when checking if a protocol handler exists. r=jmathies a=lizzard Differential Revision: https://phabricator.services.mozilla.com/D19775
uriloader/exthandler/win/nsOSHelperAppService.cpp
--- a/uriloader/exthandler/win/nsOSHelperAppService.cpp
+++ b/uriloader/exthandler/win/nsOSHelperAppService.cpp
@@ -78,16 +78,39 @@ nsresult nsOSHelperAppService::OSProtoco
     NS_ENSURE_TRUE(mAppAssoc, NS_ERROR_NOT_AVAILABLE);
     wchar_t* pResult = nullptr;
     NS_ConvertASCIItoUTF16 scheme(aProtocolScheme);
     // We are responsible for freeing returned strings.
     HRESULT hr = mAppAssoc->QueryCurrentDefault(scheme.get(), AT_URLPROTOCOL,
                                                 AL_EFFECTIVE, &pResult);
     if (SUCCEEDED(hr)) {
       CoTaskMemFree(pResult);
+      nsCOMPtr<nsIWindowsRegKey> regKey =
+          do_CreateInstance("@mozilla.org/windows-registry-key;1");
+      if (!regKey) {
+        return NS_ERROR_NOT_AVAILABLE;
+      }
+
+      nsresult rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT,
+                                 nsDependentString(scheme.get()),
+                                 nsIWindowsRegKey::ACCESS_QUERY_VALUE);
+      if (NS_FAILED(rv)) {
+        // Open will fail if the registry key path doesn't exist.
+        return NS_OK;
+      }
+
+      bool hasValue;
+      rv = regKey->HasValue(NS_LITERAL_STRING("URL Protocol"), &hasValue);
+      if (NS_FAILED(rv)) {
+        return NS_ERROR_FAILURE;
+      }
+      if (!hasValue) {
+        return NS_OK;
+      }
+
       *aHandlerExists = true;
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP nsOSHelperAppService::GetApplicationDescription(