Bug 1308160 - Correct ::deserialize for nsHostObjectURI, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 06 Oct 2016 16:36:07 +0200
changeset 421695 428876d40e6be43618726dc7bd8b903584238b04
parent 421694 c6752015a180432ee6e6697557d86a6f6e419594
child 421696 9fbc16390ef792d1b4eb14a5755f21cdd42526de
push id31560
push userbmo:tchiovoloni@mozilla.com
push dateThu, 06 Oct 2016 15:57:04 +0000
reviewerssmaug
bugs1308160
milestone52.0a1
Bug 1308160 - Correct ::deserialize for nsHostObjectURI, r=smaug
dom/base/nsHostObjectProtocolHandler.cpp
dom/base/nsHostObjectURI.cpp
--- a/dom/base/nsHostObjectProtocolHandler.cpp
+++ b/dom/base/nsHostObjectProtocolHandler.cpp
@@ -97,16 +97,17 @@ GetDataInfo(const nsACString& aUri)
   if (pos < 0) {
     gDataTable->Get(aUri, &res);
   } else {
     gDataTable->Get(StringHead(aUri, pos), &res);
   }
 
   return res;
 }
+
 static DataInfo*
 GetDataInfoFromURI(nsIURI* aURI)
 {
   if (!aURI) {
     return nullptr;
   }
 
   nsCString spec;
--- a/dom/base/nsHostObjectURI.cpp
+++ b/dom/base/nsHostObjectURI.cpp
@@ -133,25 +133,30 @@ nsHostObjectURI::Deserialize(const mozil
   }
 
   const HostObjectURIParams& hostParams = aParams.get_HostObjectURIParams();
 
   if (!mozilla::net::nsSimpleURI::Deserialize(hostParams.simpleParams())) {
     return false;
   }
 
-  // XXXbaku: when we will have shared blobURL maps, we can populate mBlobImpl
-  // here asll well.
-
   if (hostParams.principal().type() == OptionalPrincipalInfo::Tvoid_t) {
     return true;
   }
 
   mPrincipal = PrincipalInfoToPrincipal(hostParams.principal().get_PrincipalInfo());
-  return mPrincipal != nullptr;
+  if (!mPrincipal) {
+    return false;
+  }
+
+  // If this fails, we still want to complete the operation. Probably this
+  // blobURL has been revoked in the meantime.
+  NS_GetBlobForBlobURI(this, getter_AddRefs(mBlobImpl));
+
+  return true;
 }
 
 NS_IMETHODIMP
 nsHostObjectURI::SetScheme(const nsACString& aScheme)
 {
   // Disallow setting the scheme, since that could cause us to be associated
   // with a different protocol handler that doesn't expect us to be carrying
   // around a principal with nsIURIWithPrincipal.