Bug 1088617 - Handle nsIURIWithPrincipal in nsPrincipal::CheckMayLoad. r=bz
authorBobby Holley <bobbyholley@gmail.com>
Wed, 29 Oct 2014 09:21:17 +0100
changeset 212830 df5359e8c82c986d681429a1f7fc6be717253ddf
parent 212829 1ef63ad2684246520d2044dfe16bc10e41641294
child 212831 a347286d9669f3489462b365d574f0e2f3575a3c
push id27730
push usercbook@mozilla.com
push dateWed, 29 Oct 2014 12:26:03 +0000
treeherdermozilla-central@fe5c1cb8075a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1088617
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1088617 - Handle nsIURIWithPrincipal in nsPrincipal::CheckMayLoad. r=bz This mimics the logic already inside nsNullPrincipal::CheckMayLoad.
caps/nsPrincipal.cpp
--- a/caps/nsPrincipal.cpp
+++ b/caps/nsPrincipal.cpp
@@ -341,16 +341,27 @@ nsPrincipal::CheckMayLoad(nsIURI* aURI, 
    if (aAllowIfInheritsPrincipal) {
     // If the caller specified to allow loads of URIs that inherit
     // our principal, allow the load if this URI inherits its principal
     if (nsPrincipal::IsPrincipalInherited(aURI)) {
       return NS_OK;
     }
   }
 
+  // See if aURI is something like a Blob URI that is actually associated with
+  // a principal.
+  nsCOMPtr<nsIURIWithPrincipal> uriWithPrin = do_QueryInterface(aURI);
+  nsCOMPtr<nsIPrincipal> uriPrin;
+  if (uriWithPrin) {
+    uriWithPrin->GetPrincipal(getter_AddRefs(uriPrin));
+  }
+  if (uriPrin && nsIPrincipal::Subsumes(uriPrin)) {
+      return NS_OK;
+  }
+
   if (nsScriptSecurityManager::SecurityCompareURIs(mCodebase, aURI)) {
     return NS_OK;
   }
 
   // If strict file origin policy is in effect, local files will always fail
   // SecurityCompareURIs unless they are identical. Explicitly check file origin
   // policy, in that case.
   if (nsScriptSecurityManager::GetStrictFileOriginPolicy() &&