Bug 1228950 - Disallow scheme sets on nsHostObjectURI. r=bz a=lizzard
authorBobby Holley <bobbyholley@gmail.com>
Tue, 01 Dec 2015 22:06:55 -0800
changeset 296865 cf98f0335f05fca86b4002a161870017639b4793
parent 296864 1b4379347d1c7128b2759465fd13d0e9750e1f3f
child 296866 c383c019d1445c5ed4b71317a5a19bab867920f7
push id5378
push userkwierso@gmail.com
push dateThu, 03 Dec 2015 19:12:06 +0000
treeherdermozilla-beta@cf98f0335f05 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, lizzard
bugs1228950
milestone43.0
Bug 1228950 - Disallow scheme sets on nsHostObjectURI. r=bz a=lizzard
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