Bug 1228950 - Disallow scheme sets on nsHostObjectURI. r=bz
authorBobby Holley <bobbyholley@gmail.com>
Tue, 01 Dec 2015 22:06:55 -0800
changeset 313762 d873179a7da024a8d42b73e571d64b1eb53efa63
parent 313761 f7ee42669b87f05416eb785ab9db27b5c66de1a3
child 313763 2d2e1828198272efcc76d0a62b54cfd146143534
push id8126
push usermstange@themasta.com
push dateThu, 03 Dec 2015 14:22:49 +0000
reviewersbz
bugs1228950
milestone45.0a1
Bug 1228950 - Disallow scheme sets on nsHostObjectURI. r=bz
dom/base/nsHostObjectURI.cpp
dom/base/nsHostObjectURI.h
--- a/dom/base/nsHostObjectURI.cpp
+++ b/dom/base/nsHostObjectURI.cpp
@@ -130,16 +130,25 @@ nsHostObjectURI::Deserialize(const mozil
   if (hostParams.principal().type() == OptionalPrincipalInfo::Tvoid_t) {
     return true;
   }
 
   mPrincipal = PrincipalInfoToPrincipal(hostParams.principal().get_PrincipalInfo());
   return mPrincipal != nullptr;
 }
 
+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.
+  return NS_ERROR_FAILURE;
+}
+
 // nsIURI methods:
 nsresult
 nsHostObjectURI::CloneInternal(nsSimpleURI::RefHandlingEnum aRefHandlingMode,
                                nsIURI** aClone)
 {
   nsCOMPtr<nsIURI> simpleClone;
   nsresult rv =
     nsSimpleURI::CloneInternal(aRefHandlingMode, getter_AddRefs(simpleClone));
--- a/dom/base/nsHostObjectURI.h
+++ b/dom/base/nsHostObjectURI.h
@@ -33,16 +33,18 @@ public:
   nsHostObjectURI() : nsSimpleURI() {}
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIURIWITHPRINCIPAL
   NS_DECL_NSISERIALIZABLE
   NS_DECL_NSICLASSINFO
   NS_DECL_NSIIPCSERIALIZABLEURI
 
+  NS_IMETHOD SetScheme(const nsACString &aProtocol) override;
+
   // Override CloneInternal() and EqualsInternal()
   virtual nsresult CloneInternal(RefHandlingEnum aRefHandlingMode,
                                  nsIURI** aClone) override;
   virtual nsresult EqualsInternal(nsIURI* aOther,
                                   RefHandlingEnum aRefHandlingMode,
                                   bool* aResult) override;
 
   // Override StartClone to hand back a nsHostObjectURI