Bug 1228950 - Disallow scheme sets on nsHostObjectURI. r=bz, a=lizzard
--- a/dom/base/nsHostObjectURI.cpp
+++ b/dom/base/nsHostObjectURI.cpp
@@ -76,16 +76,25 @@ nsHostObjectURI::Write(nsIObjectOutputSt
nsresult rv = nsSimpleURI::Write(aStream);
NS_ENSURE_SUCCESS(rv, rv);
return NS_WriteOptionalCompoundObject(aStream, mPrincipal,
NS_GET_IID(nsIPrincipal),
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.
+ 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
@@ -29,16 +29,18 @@ public:
// For use only from deserialization
nsHostObjectURI() : nsSimpleURI() {}
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIURIWITHPRINCIPAL
NS_DECL_NSISERIALIZABLE
NS_DECL_NSICLASSINFO
+ 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