Bug 1544008 - re-allow systemprincipal load for discovery pane r=ckerschb

Differential Revision: https://phabricator.services.mozilla.com/D27291

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Frederik Braun 2019-04-12 15:06:13 +00:00
parent cea888163f
commit d372b94f5f

View File

@ -776,6 +776,27 @@ static void AssertSystemPrincipalMustNotLoadRemoteDocuments(
!nsContentUtils::SchemeIs(finalURI, "ftp")) {
return;
}
// FIXME The discovery feature in about:addons uses the SystemPrincpal.
// We should remove this exception with bug 1544011.
static nsAutoCString sDiscoveryPrePath;
static bool recvdPrefValue = false;
if (!recvdPrefValue) {
nsAutoCString discoveryURLString;
Preferences::GetCString("extensions.webservice.discoverURL", discoveryURLString);
// discoverURL is by default suffixed with parameters in path like /%LOCALE%/
// so, we use the prePath for comparison
nsCOMPtr<nsIURI> discoveryURL;
NS_NewURI(getter_AddRefs(discoveryURL), discoveryURLString);
discoveryURL->GetPrePath(sDiscoveryPrePath);
recvdPrefValue = true;
}
nsAutoCString requestedPrePath;
finalURI->GetPrePath(requestedPrePath);
if (requestedPrePath.Equals(sDiscoveryPrePath)) {
return;
}
if (xpc::AreNonLocalConnectionsDisabled()) {
bool disallowSystemPrincipalRemoteDocuments = Preferences::GetBool(
"security.disallow_non_local_systemprincipal_in_tests");