@@ -670,6 +670,21 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal,
670
670
return NS_ERROR_DOM_BAD_URI;
671
671
}
672
672
673
+ // Extensions may allow access to a web accessible resource.
674
+ bool maybeWebAccessible = false ;
675
+ NS_URIChainHasFlags (targetBaseURI,
676
+ nsIProtocolHandler::WEBEXT_URI_WEB_ACCESSIBLE,
677
+ &maybeWebAccessible);
678
+ NS_ENSURE_SUCCESS (rv, rv);
679
+ if (maybeWebAccessible) {
680
+ bool isWebAccessible = false ;
681
+ rv = ExtensionPolicyService::GetSingleton ().SourceMayLoadExtensionURI (
682
+ sourceURI, targetBaseURI, &isWebAccessible);
683
+ if (!(NS_SUCCEEDED(rv) && isWebAccessible)) {
684
+ return NS_ERROR_DOM_BAD_URI;
685
+ }
686
+ }
687
+
673
688
// Check for uris that are only loadable by principals that subsume them
674
689
bool targetURIIsLoadableBySubsumers = false ;
675
690
rv = NS_URIChainHasFlags(targetBaseURI,
@@ -743,7 +758,6 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal,
743
758
bool schemesMatch =
744
759
scheme.Equals (otherScheme, nsCaseInsensitiveCStringComparator);
745
760
bool isSamePage = false ;
746
- bool isExtensionMismatch = false ;
747
761
// about: URIs are special snowflakes.
748
762
if (scheme.EqualsLiteral (" about" ) && schemesMatch) {
749
763
nsAutoCString moduleName, otherModuleName;
@@ -791,13 +805,6 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal,
791
805
}
792
806
}
793
807
}
794
- } else if (schemesMatch && scheme.EqualsLiteral(" moz-extension" )) {
795
- // If it is not the same exension, we want to ensure we end up
796
- // calling CheckLoadURIFlags
797
- nsAutoCString host, otherHost;
798
- currentURI->GetHost (host);
799
- currentOtherURI->GetHost (otherHost);
800
- isExtensionMismatch = !host.Equals (otherHost);
801
808
} else {
802
809
bool equalExceptRef = false ;
803
810
rv = currentURI->EqualsExceptRef (currentOtherURI, &equalExceptRef);
@@ -806,12 +813,10 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal,
806
813
807
814
// If schemes are not equal, or they're equal but the target URI
808
815
// is different from the source URI and doesn't always allow linking
809
- // from the same scheme, or this is two different extensions, check
810
- // if the URI flags of the current target URI allow the current
811
- // source URI to link to it.
816
+ // from the same scheme, check if the URI flags of the current target
817
+ // URI allow the current source URI to link to it.
812
818
// The policy is specified by the protocol flags on both URIs.
813
- if (!schemesMatch || (denySameSchemeLinks && !isSamePage) ||
814
- isExtensionMismatch) {
819
+ if (!schemesMatch || (denySameSchemeLinks && !isSamePage)) {
815
820
return CheckLoadURIFlags (
816
821
currentURI, currentOtherURI, sourceBaseURI, targetBaseURI, aFlags,
817
822
aPrincipal->OriginAttributesRef ().mPrivateBrowsingId > 0 ,
@@ -886,25 +891,6 @@ nsresult nsScriptSecurityManager::CheckLoadURIFlags(
886
891
}
887
892
}
888
893
889
- // If Extension uris are web accessible they have WEBEXT_URI_WEB_ACCESSIBLE.
890
- bool maybeWebAccessible = false ;
891
- NS_URIChainHasFlags (aTargetURI, nsIProtocolHandler::WEBEXT_URI_WEB_ACCESSIBLE,
892
- &maybeWebAccessible);
893
- NS_ENSURE_SUCCESS (rv, rv);
894
- if (maybeWebAccessible) {
895
- bool isWebAccessible = false ;
896
- rv = ExtensionPolicyService::GetSingleton ().SourceMayLoadExtensionURI (
897
- aSourceURI, aTargetURI, &isWebAccessible);
898
- if (NS_SUCCEEDED(rv) && isWebAccessible) {
899
- return NS_OK;
900
- }
901
- if (reportErrors) {
902
- ReportError (errorTag, aSourceURI, aTargetURI, aFromPrivateWindow,
903
- aInnerWindowID);
904
- }
905
- return NS_ERROR_DOM_BAD_URI;
906
- }
907
-
908
894
// Check for chrome target URI
909
895
bool targetURIIsUIResource = false ;
910
896
rv = NS_URIChainHasFlags(aTargetURI, nsIProtocolHandler::URI_IS_UI_RESOURCE,
0 commit comments