diff --git a/caps/ContentPrincipal.cpp b/caps/ContentPrincipal.cpp index 03ca5fea9963..1f118edef612 100644 --- a/caps/ContentPrincipal.cpp +++ b/caps/ContentPrincipal.cpp @@ -36,16 +36,6 @@ using namespace mozilla; -static bool URIIsImmutable(nsIURI* aURI) -{ - nsCOMPtr mutableObj(do_QueryInterface(aURI)); - bool isMutable; - return - mutableObj && - NS_SUCCEEDED(mutableObj->GetMutable(&isMutable)) && - !isMutable; -} - static inline ExtensionPolicyService& EPS() { @@ -63,8 +53,6 @@ NS_IMPL_CI_INTERFACE_GETTER(ContentPrincipal, ContentPrincipal::ContentPrincipal() : BasePrincipal(eCodebasePrincipal) - , mCodebaseImmutable(false) - , mDomainImmutable(false) { } @@ -96,9 +84,7 @@ ContentPrincipal::Init(nsIURI *aCodebase, &hasFlag)) && !hasFlag); - mCodebase = NS_TryToMakeImmutable(aCodebase); - mCodebaseImmutable = URIIsImmutable(mCodebase); - + mCodebase = aCodebase; FinishInit(aOriginNoSuffix, aOriginAttributes); return NS_OK; @@ -278,17 +264,8 @@ ContentPrincipal::SubsumesInternal(nsIPrincipal* aOther, NS_IMETHODIMP ContentPrincipal::GetURI(nsIURI** aURI) { - if (mCodebaseImmutable) { - NS_ADDREF(*aURI = mCodebase); - return NS_OK; - } - - if (!mCodebase) { - *aURI = nullptr; - return NS_OK; - } - - return NS_EnsureSafeToReturn(mCodebase, aURI); + NS_ADDREF(*aURI = mCodebase); + return NS_OK; } bool @@ -344,19 +321,14 @@ ContentPrincipal::GetDomain(nsIURI** aDomain) return NS_OK; } - if (mDomainImmutable) { - NS_ADDREF(*aDomain = mDomain); - return NS_OK; - } - - return NS_EnsureSafeToReturn(mDomain, aDomain); + NS_ADDREF(*aDomain = mDomain); + return NS_OK; } NS_IMETHODIMP ContentPrincipal::SetDomain(nsIURI* aDomain) { - mDomain = NS_TryToMakeImmutable(aDomain); - mDomainImmutable = URIIsImmutable(mDomain); + mDomain = aDomain; SetHasExplicitDomain(); // Recompute all wrappers between compartments using this principal and other @@ -516,8 +488,5 @@ ContentPrincipal::Write(nsIObjectOutputStream* aStream) return rv; } - // mCodebaseImmutable and mDomainImmutable will be recomputed based - // on the deserialized URIs in Read(). - return NS_OK; } diff --git a/caps/ContentPrincipal.h b/caps/ContentPrincipal.h index fa7c2ff09c8f..15cc094efb81 100644 --- a/caps/ContentPrincipal.h +++ b/caps/ContentPrincipal.h @@ -47,9 +47,6 @@ public: nsCOMPtr mDomain; nsCOMPtr mCodebase; - // If mCodebaseImmutable is true, mCodebase is non-null and immutable - bool mCodebaseImmutable; - bool mDomainImmutable; protected: virtual ~ContentPrincipal(); diff --git a/caps/NullPrincipal.cpp b/caps/NullPrincipal.cpp index 676d813c7196..1ffe8414717a 100644 --- a/caps/NullPrincipal.cpp +++ b/caps/NullPrincipal.cpp @@ -160,13 +160,17 @@ NullPrincipal::SetCsp(nsIContentSecurityPolicy* aCsp) NS_IMETHODIMP NullPrincipal::GetURI(nsIURI** aURI) { - return NS_EnsureSafeToReturn(mURI, aURI); + nsCOMPtr uri = mURI; + uri.forget(aURI); + return NS_OK; } NS_IMETHODIMP NullPrincipal::GetDomain(nsIURI** aDomain) { - return NS_EnsureSafeToReturn(mURI, aDomain); + nsCOMPtr uri = mURI; + uri.forget(aDomain); + return NS_OK; } NS_IMETHODIMP diff --git a/chrome/nsChromeProtocolHandler.cpp b/chrome/nsChromeProtocolHandler.cpp index 9dc0e842fb0c..1f1f1365df2e 100644 --- a/chrome/nsChromeProtocolHandler.cpp +++ b/chrome/nsChromeProtocolHandler.cpp @@ -97,8 +97,6 @@ nsChromeProtocolHandler::NewURI(const nsACString &aSpec, if (NS_FAILED(rv)) return rv; - NS_TryToSetImmutable(surl); - surl.forget(result); return NS_OK; } diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 052c8d3c222e..e967650c9e68 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -1430,7 +1430,7 @@ nsDocShell::SetCurrentURI(nsIURI* aURI, nsIRequest* aRequest, return false; } - mCurrentURI = NS_TryToMakeImmutable(aURI); + mCurrentURI = aURI; if (!NS_IsAboutBlank(mCurrentURI)) { mHasLoadedNonBlankURI = true; @@ -5192,11 +5192,8 @@ nsDocShell::GetCurrentURI(nsIURI** aURI) { NS_ENSURE_ARG_POINTER(aURI); - if (mCurrentURI) { - return NS_EnsureSafeToReturn(mCurrentURI, aURI); - } - - *aURI = nullptr; + nsCOMPtr uri = mCurrentURI; + uri.forget(aURI); return NS_OK; } diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 535195ee3b6a..67e3ef8c6433 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -3695,9 +3695,6 @@ nsContentUtils::LoadImage(nsIURI* aURI, nsINode* aContext, NS_ASSERTION(loadGroup || IsFontTableURI(documentURI), "Could not get loadgroup; onload may fire too early"); - // Make the URI immutable so people won't change it under us - NS_TryToSetImmutable(aURI); - // XXXbz using "documentURI" for the initialDocumentURI is not quite // right, but the best we can do here... return imgLoader->LoadImage(aURI, /* uri to load */ diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 5b2e104bbecc..bf74d97d7580 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -3014,7 +3014,7 @@ void nsIDocument::SetDocumentURI(nsIURI* aURI) { nsCOMPtr oldBase = GetDocBaseURI(); - mDocumentURI = NS_TryToMakeImmutable(aURI); + mDocumentURI = aURI; nsIURI* newBase = GetDocBaseURI(); bool equalBases = false; @@ -3629,11 +3629,7 @@ nsIDocument::SetBaseURI(nsIURI* aURI) } } - if (aURI) { - mDocumentBaseURI = NS_TryToMakeImmutable(aURI); - } else { - mDocumentBaseURI = nullptr; - } + mDocumentBaseURI = aURI; RefreshLinkHrefs(); } diff --git a/dom/base/nsImageLoadingContent.cpp b/dom/base/nsImageLoadingContent.cpp index 1c15219bf873..50d51f3d6230 100644 --- a/dom/base/nsImageLoadingContent.cpp +++ b/dom/base/nsImageLoadingContent.cpp @@ -732,11 +732,8 @@ nsImageLoadingContent::GetCurrentURI(ErrorResult& aError) nsCOMPtr uri; if (mCurrentRequest) { mCurrentRequest->GetURI(getter_AddRefs(uri)); - } else if (mCurrentURI) { - nsresult rv = NS_EnsureSafeToReturn(mCurrentURI, getter_AddRefs(uri)); - if (NS_FAILED(rv)) { - aError.Throw(rv); - } + } else { + uri = mCurrentURI; } return uri.forget(); @@ -872,8 +869,6 @@ nsImageLoadingContent::LoadImage(const nsAString& aNewURI, NS_ENSURE_SUCCESS(rv, rv); // XXXbiesi fire onerror if that failed? - NS_TryToSetImmutable(imageURI); - return LoadImage(imageURI, aForce, aNotify, aImageLoadType, false, doc, nsIRequest::LOAD_NORMAL, aTriggeringPrincipal); } diff --git a/dom/base/nsObjectLoadingContent.cpp b/dom/base/nsObjectLoadingContent.cpp index 7257f50f63b3..c4bfdf1bc18d 100644 --- a/dom/base/nsObjectLoadingContent.cpp +++ b/dom/base/nsObjectLoadingContent.cpp @@ -1603,9 +1603,7 @@ nsObjectLoadingContent::UpdateObjectParameters() codebaseStr, thisElement->OwnerDoc(), docBaseURI); - if (NS_SUCCEEDED(rv)) { - NS_TryToSetImmutable(newBaseURI); - } else { + if (NS_FAILED(rv)) { // Malformed URI LOG(("OBJLC [%p]: Could not parse plugin's codebase as a URI, " "will use document baseURI instead", this)); @@ -1656,9 +1654,7 @@ nsObjectLoadingContent::UpdateObjectParameters() newMime = NS_LITERAL_CSTRING("text/html"); } - if (NS_SUCCEEDED(rv)) { - NS_TryToSetImmutable(newURI); - } else { + if (NS_FAILED(rv)) { stateInvalid = true; } } diff --git a/dom/html/nsHTMLDocument.cpp b/dom/html/nsHTMLDocument.cpp index a5bd6e6f1051..d6d8507167eb 100644 --- a/dom/html/nsHTMLDocument.cpp +++ b/dom/html/nsHTMLDocument.cpp @@ -1041,7 +1041,6 @@ nsHTMLDocument::SetDomain(const nsAString& aDomain, ErrorResult& rv) return; } - NS_TryToSetImmutable(newURI); rv = NodePrincipal()->SetDomain(newURI); } diff --git a/ipc/glue/URIParams.ipdlh b/ipc/glue/URIParams.ipdlh index 86b0db486b84..9d4a86f6eea5 100644 --- a/ipc/glue/URIParams.ipdlh +++ b/ipc/glue/URIParams.ipdlh @@ -16,7 +16,6 @@ struct SimpleURIParams nsCString path; nsCString ref; nsCString query; - bool isMutable; }; struct StandardURLSegment @@ -43,7 +42,6 @@ struct StandardURLParams StandardURLSegment extension; StandardURLSegment query; StandardURLSegment ref; - bool isMutable; bool supportsFileURL; }; diff --git a/modules/libjar/nsJARURI.cpp b/modules/libjar/nsJARURI.cpp index 0382cf51937c..b42400f68b3a 100644 --- a/modules/libjar/nsJARURI.cpp +++ b/modules/libjar/nsJARURI.cpp @@ -407,8 +407,6 @@ nsJARURI::SetSpecWithBase(const nsACString &aSpec, nsIURI* aBaseURL) aBaseURL, getter_AddRefs(mJARFile)); if (NS_FAILED(rv)) return rv; - NS_TryToSetImmutable(mJARFile); - // skip over any extra '/' chars while (*delim_end == '/') ++delim_end; @@ -922,8 +920,6 @@ nsJARURI::CloneWithJARFileInternal(nsIURI *jarFile, rv = jarFile->Clone(getter_AddRefs(newJARFile)); if (NS_FAILED(rv)) return rv; - NS_TryToSetImmutable(newJARFile); - nsCOMPtr newJAREntryURI; if (refHandlingMode == eHonorRef) { rv = mJAREntry->Clone(getter_AddRefs(newJAREntryURI)); @@ -949,9 +945,11 @@ nsJARURI::CloneWithJARFileInternal(nsIURI *jarFile, //////////////////////////////////////////////////////////////////////////////// NS_IMETHODIMP -nsJARURI::GetInnerURI(nsIURI **uri) +nsJARURI::GetInnerURI(nsIURI **aURI) { - return NS_EnsureSafeToReturn(mJARFile, uri); + nsCOMPtr uri = mJARFile; + uri.forget(aURI); + return NS_OK; } NS_IMETHODIMP diff --git a/netwerk/base/nsINetUtil.idl b/netwerk/base/nsINetUtil.idl index 8bf99ebecc6a..044e614b63ef 100644 --- a/netwerk/base/nsINetUtil.idl +++ b/netwerk/base/nsINetUtil.idl @@ -75,14 +75,6 @@ interface nsINetUtil : nsISupports */ boolean URIChainHasFlags(in nsIURI aURI, in unsigned long aFlags); - /** - * Take aURI and produce an immutable version of it for the caller. If aURI - * is immutable this will be aURI itself; otherwise this will be a clone, - * marked immutable if possible. Passing null to this method is allowed; in - * that case it will return null. - */ - nsIURI toImmutableURI(in nsIURI aURI); - /** Escape every character with its %XX-escaped equivalent */ const unsigned long ESCAPE_ALL = 0; diff --git a/netwerk/base/nsIOService.cpp b/netwerk/base/nsIOService.cpp index 113b7025b880..9ff7563382db 100644 --- a/netwerk/base/nsIOService.cpp +++ b/netwerk/base/nsIOService.cpp @@ -1600,21 +1600,6 @@ nsIOService::URIChainHasFlags(nsIURI *uri, return rv; } -NS_IMETHODIMP -nsIOService::ToImmutableURI(nsIURI* uri, nsIURI** result) -{ - if (!uri) { - *result = nullptr; - return NS_OK; - } - - nsresult rv = NS_EnsureSafeToReturn(uri, result); - NS_ENSURE_SUCCESS(rv, rv); - - NS_TryToSetImmutable(*result); - return NS_OK; -} - NS_IMETHODIMP nsIOService::SetManageOfflineStatus(bool aManage) { diff --git a/netwerk/base/nsIStandardURL.idl b/netwerk/base/nsIStandardURL.idl index 633d184abc39..dae8ecc13c81 100644 --- a/netwerk/base/nsIStandardURL.idl +++ b/netwerk/base/nsIStandardURL.idl @@ -3,7 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "nsIMutable.idl" +#include "nsISupports.idl" interface nsIURI; interface nsIURIMutator; @@ -15,7 +15,7 @@ interface nsIURIMutator; * some customization on how URLs are normalized. */ [scriptable, builtinclass, uuid(babd6cca-ebe7-4329-967c-d6b9e33caa81)] -interface nsIStandardURL : nsIMutable +interface nsIStandardURL : nsISupports { /** * blah:foo/bar => blah://foo/bar diff --git a/netwerk/base/nsNetUtil.cpp b/netwerk/base/nsNetUtil.cpp index 0754ff18e8da..44cc35508e29 100644 --- a/netwerk/base/nsNetUtil.cpp +++ b/netwerk/base/nsNetUtil.cpp @@ -2343,66 +2343,6 @@ NS_ImplGetInnermostURI(nsINestedURI *nestedURI, nsIURI **result) return NS_DoImplGetInnermostURI(nestedURI, result); } -nsresult -NS_EnsureSafeToReturn(nsIURI *uri, nsIURI **result) -{ - MOZ_ASSERT(uri, "Must have a URI"); - - // Assume mutable until told otherwise - bool isMutable = true; - nsCOMPtr mutableObj(do_QueryInterface(uri)); - if (mutableObj) { - nsresult rv = mutableObj->GetMutable(&isMutable); - isMutable = NS_FAILED(rv) || isMutable; - } - - if (!isMutable) { - NS_ADDREF(*result = uri); - return NS_OK; - } - - nsresult rv = uri->Clone(result); - if (NS_SUCCEEDED(rv) && !*result) { - NS_ERROR("nsIURI.clone contract was violated"); - return NS_ERROR_UNEXPECTED; - } - - return rv; -} - -void -NS_TryToSetImmutable(nsIURI *uri) -{ - nsCOMPtr mutableObj(do_QueryInterface(uri)); - if (mutableObj) { - mutableObj->SetMutable(false); - } -} - -already_AddRefed -NS_TryToMakeImmutable(nsIURI *uri, - nsresult *outRv /* = nullptr */) -{ - nsresult rv; - nsCOMPtr util = do_GetNetUtil(&rv); - - nsCOMPtr result; - if (NS_SUCCEEDED(rv)) { - NS_ASSERTION(util, "do_GetNetUtil lied"); - rv = util->ToImmutableURI(uri, getter_AddRefs(result)); - } - - if (NS_FAILED(rv)) { - result = uri; - } - - if (outRv) { - *outRv = rv; - } - - return result.forget(); -} - already_AddRefed NS_GetInnermostURI(nsIURI *aURI) { diff --git a/netwerk/base/nsNetUtil.h b/netwerk/base/nsNetUtil.h index b3f31587c820..abd587a223dc 100644 --- a/netwerk/base/nsNetUtil.h +++ b/netwerk/base/nsNetUtil.h @@ -793,26 +793,6 @@ nsresult NS_DoImplGetInnermostURI(nsINestedURI *nestedURI, nsIURI **result); nsresult NS_ImplGetInnermostURI(nsINestedURI *nestedURI, nsIURI **result); -/** - * Helper function that ensures that |result| is a URI that's safe to - * return. If |uri| is immutable, just returns it, otherwise returns - * a clone. |uri| must not be null. - */ -nsresult NS_EnsureSafeToReturn(nsIURI *uri, nsIURI **result); - -/** - * Helper function that tries to set the argument URI to be immutable - */ -void NS_TryToSetImmutable(nsIURI *uri); - -/** - * Helper function for calling ToImmutableURI. If all else fails, returns - * the input URI. The optional second arg indicates whether we had to fall - * back to the input URI. Passing in a null URI is ok. - */ -already_AddRefed NS_TryToMakeImmutable(nsIURI *uri, - nsresult *outRv = nullptr); - /** * Helper function for testing whether the given URI, or any of its * inner URIs, has all the given protocol flags. diff --git a/netwerk/base/nsSimpleNestedURI.cpp b/netwerk/base/nsSimpleNestedURI.cpp index f2c3786ce2cf..55915720670f 100644 --- a/netwerk/base/nsSimpleNestedURI.cpp +++ b/netwerk/base/nsSimpleNestedURI.cpp @@ -22,7 +22,6 @@ nsSimpleNestedURI::nsSimpleNestedURI(nsIURI* innerURI) : mInnerURI(innerURI) { NS_ASSERTION(innerURI, "Must have inner URI"); - NS_TryToSetImmutable(innerURI); } // nsISerializable @@ -40,8 +39,6 @@ nsSimpleNestedURI::ReadPrivate(nsIObjectInputStream *aStream) nsresult rv = nsSimpleURI::ReadPrivate(aStream); if (NS_FAILED(rv)) return rv; - NS_ASSERTION(!mMutable, "How did that happen?"); - nsCOMPtr supports; rv = aStream->ReadObject(true, getter_AddRefs(supports)); if (NS_FAILED(rv)) return rv; @@ -49,8 +46,6 @@ nsSimpleNestedURI::ReadPrivate(nsIObjectInputStream *aStream) mInnerURI = do_QueryInterface(supports, &rv); if (NS_FAILED(rv)) return rv; - NS_TryToSetImmutable(mInnerURI); - return rv; } @@ -103,19 +98,19 @@ nsSimpleNestedURI::Deserialize(const mozilla::ipc::URIParams& aParams) return false; mInnerURI = DeserializeURI(params.innerURI()); - - NS_TryToSetImmutable(mInnerURI); return true; } // nsINestedURI NS_IMETHODIMP -nsSimpleNestedURI::GetInnerURI(nsIURI** uri) +nsSimpleNestedURI::GetInnerURI(nsIURI** aURI) { NS_ENSURE_TRUE(mInnerURI, NS_ERROR_NOT_INITIALIZED); - return NS_EnsureSafeToReturn(mInnerURI, uri); + nsCOMPtr uri = mInnerURI; + uri.forget(aURI); + return NS_OK; } NS_IMETHODIMP @@ -177,7 +172,6 @@ nsSimpleNestedURI::StartClone(nsSimpleURI::RefHandlingEnum refHandlingMode, nsSimpleNestedURI* url = new nsSimpleNestedURI(innerClone); SetRefOnClone(url, refHandlingMode, newRef); - url->SetMutable(false); return url; } @@ -208,9 +202,6 @@ nsSimpleNestedURI::Mutate(nsIURIMutator** aMutator) if (NS_FAILED(rv)) { return rv; } - // StartClone calls SetMutable(false) but we need the mutator clone - // to be mutable - mutator->ResetMutable(); mutator.forget(aMutator); return NS_OK; } diff --git a/netwerk/base/nsSimpleNestedURI.h b/netwerk/base/nsSimpleNestedURI.h index 75913efead87..70935d33074f 100644 --- a/netwerk/base/nsSimpleNestedURI.h +++ b/netwerk/base/nsSimpleNestedURI.h @@ -6,11 +6,7 @@ /** * URI class to be used for cases when a simple URI actually resolves to some * other sort of URI, with the latter being what's loaded when the load - * happens. All objects of this class should always be immutable, so that the - * inner URI and this URI don't get out of sync. The Clone() implementation - * will guarantee this for the clone, but it's up to the protocol handlers - * creating these URIs to ensure that in the first place. The innerURI passed - * to this URI will be set immutable if possible. + * happens. */ #ifndef nsSimpleNestedURI_h__ @@ -100,7 +96,6 @@ public: MOZ_MUST_USE NS_IMETHOD Finalize(nsIURI** aURI) override { - mURI->mMutable = false; mURI.forget(aURI); return NS_OK; } @@ -121,13 +116,6 @@ public: return NS_OK; } - void ResetMutable() - { - if (mURI) { - mURI->mMutable = true; - } - } - friend class nsSimpleNestedURI; }; diff --git a/netwerk/base/nsSimpleURI.cpp b/netwerk/base/nsSimpleURI.cpp index 24f49791a7e1..85a42408f578 100644 --- a/netwerk/base/nsSimpleURI.cpp +++ b/netwerk/base/nsSimpleURI.cpp @@ -49,8 +49,7 @@ nsSimpleURI::From(nsIURI* aURI) // nsSimpleURI methods: nsSimpleURI::nsSimpleURI() - : mMutable(true) - , mIsRefValid(false) + : mIsRefValid(false) , mIsQueryValid(false) { } @@ -59,7 +58,7 @@ NS_IMPL_ADDREF(nsSimpleURI) NS_IMPL_RELEASE(nsSimpleURI) NS_INTERFACE_TABLE_HEAD(nsSimpleURI) NS_INTERFACE_TABLE(nsSimpleURI, nsIURI, nsISerializable, - nsIClassInfo, nsIMutable, nsIIPCSerializableURI) + nsIClassInfo, nsIIPCSerializableURI) NS_INTERFACE_TABLE_TO_MAP_SEGUE if (aIID.Equals(kThisSimpleURIImplementationCID)) foundInterface = static_cast(this); @@ -85,7 +84,7 @@ nsSimpleURI::ReadPrivate(nsIObjectInputStream *aStream) bool isMutable; rv = aStream->ReadBoolean(&isMutable); if (NS_FAILED(rv)) return rv; - mMutable = isMutable; + Unused << isMutable; rv = aStream->ReadCString(mScheme); if (NS_FAILED(rv)) return rv; @@ -125,7 +124,7 @@ nsSimpleURI::Write(nsIObjectOutputStream* aStream) { nsresult rv; - rv = aStream->WriteBoolean(mMutable); + rv = aStream->WriteBoolean(false); // former mMutable if (NS_FAILED(rv)) return rv; rv = aStream->WriteStringZ(mScheme.get()); @@ -176,8 +175,6 @@ nsSimpleURI::Serialize(URIParams& aParams) params.query().SetIsVoid(true); } - params.isMutable() = mMutable; - aParams = params; } @@ -210,8 +207,6 @@ nsSimpleURI::Deserialize(const URIParams& aParams) mIsQueryValid = true; } - mMutable = params.isMutable(); - return true; } @@ -293,8 +288,6 @@ nsSimpleURI::GetHasRef(bool *result) nsresult nsSimpleURI::SetSpecInternal(const nsACString &aSpec) { - NS_ENSURE_STATE(mMutable); - nsresult rv = net_ExtractURLScheme(aSpec, mScheme); if (NS_FAILED(rv)) { return rv; @@ -323,8 +316,6 @@ nsSimpleURI::GetScheme(nsACString &result) nsresult nsSimpleURI::SetScheme(const nsACString &scheme) { - NS_ENSURE_STATE(mMutable); - const nsPromiseFlatCString &flat = PromiseFlatCString(scheme); if (!net_IsValidScheme(flat)) { NS_WARNING("the given url scheme contains invalid characters"); @@ -364,8 +355,6 @@ nsSimpleURI::GetUsername(nsACString &result) nsresult nsSimpleURI::SetUsername(const nsACString &userName) { - NS_ENSURE_STATE(mMutable); - return NS_ERROR_FAILURE; } @@ -378,8 +367,6 @@ nsSimpleURI::GetPassword(nsACString &result) nsresult nsSimpleURI::SetPassword(const nsACString &password) { - NS_ENSURE_STATE(mMutable); - return NS_ERROR_FAILURE; } @@ -395,8 +382,6 @@ nsSimpleURI::GetHostPort(nsACString &result) nsresult nsSimpleURI::SetHostPort(const nsACString &result) { - NS_ENSURE_STATE(mMutable); - return NS_ERROR_FAILURE; } @@ -411,8 +396,6 @@ nsSimpleURI::GetHost(nsACString &result) nsresult nsSimpleURI::SetHost(const nsACString &host) { - NS_ENSURE_STATE(mMutable); - return NS_ERROR_FAILURE; } @@ -427,8 +410,6 @@ nsSimpleURI::GetPort(int32_t *result) nsresult nsSimpleURI::SetPort(int32_t port) { - NS_ENSURE_STATE(mMutable); - return NS_ERROR_FAILURE; } @@ -449,8 +430,6 @@ nsSimpleURI::GetPathQueryRef(nsACString &result) nsresult nsSimpleURI::SetPathQueryRef(const nsACString &aPath) { - NS_ENSURE_STATE(mMutable); - return SetPathQueryRefEscaped(aPath, true); } nsresult @@ -532,8 +511,6 @@ nsSimpleURI::GetRef(nsACString &result) nsresult nsSimpleURI::SetRef(const nsACString &aRef) { - NS_ENSURE_STATE(mMutable); - nsAutoCString ref; nsresult rv = NS_EscapeURL(aRef, esc_OnlyNonASCII, ref, fallible); if (NS_FAILED(rv)) { @@ -677,8 +654,6 @@ nsSimpleURI::CloneInternal(nsSimpleURI::RefHandlingEnum refHandlingMode, if (!url) return NS_ERROR_OUT_OF_MEMORY; - // Note: |url| may well have mMutable false at this point, so - // don't call any setter methods. url->mScheme = mScheme; url->mPath = mPath; @@ -781,25 +756,6 @@ nsSimpleURI::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) return NS_OK; } -//---------------------------------------------------------------------------- -// nsSimpleURI::nsISimpleURI -//---------------------------------------------------------------------------- -NS_IMETHODIMP -nsSimpleURI::GetMutable(bool *value) -{ - *value = mMutable; - return NS_OK; -} - -NS_IMETHODIMP -nsSimpleURI::SetMutable(bool value) -{ - NS_ENSURE_ARG(mMutable || !value); - - mMutable = value; - return NS_OK; -} - //---------------------------------------------------------------------------- // nsSimpleURI::nsISizeOf //---------------------------------------------------------------------------- @@ -846,8 +802,6 @@ nsSimpleURI::GetQuery(nsACString& aQuery) nsresult nsSimpleURI::SetQuery(const nsACString& aQuery) { - NS_ENSURE_STATE(mMutable); - nsAutoCString query; nsresult rv = NS_EscapeURL(aQuery, esc_OnlyNonASCII, query, fallible); if (NS_FAILED(rv)) { diff --git a/netwerk/base/nsSimpleURI.h b/netwerk/base/nsSimpleURI.h index b549d0388772..6f762a0ba227 100644 --- a/netwerk/base/nsSimpleURI.h +++ b/netwerk/base/nsSimpleURI.h @@ -11,7 +11,6 @@ #include "nsISerializable.h" #include "nsString.h" #include "nsIClassInfo.h" -#include "nsIMutable.h" #include "nsISizeOf.h" #include "nsIIPCSerializableURI.h" #include "nsIURIMutator.h" @@ -31,7 +30,6 @@ class nsSimpleURI : public nsIURI , public nsISerializable , public nsIClassInfo - , public nsIMutable , public nsISizeOf , public nsIIPCSerializableURI { @@ -44,7 +42,6 @@ public: NS_DECL_NSIURI NS_DECL_NSISERIALIZABLE NS_DECL_NSICLASSINFO - NS_DECL_NSIMUTABLE NS_DECL_NSIIPCSERIALIZABLEURI static already_AddRefed From(nsIURI* aURI); diff --git a/netwerk/base/nsStandardURL.cpp b/netwerk/base/nsStandardURL.cpp index b22a4f1247d9..d182bc943996 100644 --- a/netwerk/base/nsStandardURL.cpp +++ b/netwerk/base/nsStandardURL.cpp @@ -78,16 +78,6 @@ constexpr bool TestForInvalidHostCharacters(char c) } constexpr ASCIIMaskArray sInvalidHostChars = CreateASCIIMask(TestForInvalidHostCharacters); -//---------------------------------------------------------------------------- - -#define ENSURE_MUTABLE() \ - PR_BEGIN_MACRO \ - if (!mMutable) { \ - NS_WARNING("attempt to modify an immutable nsStandardURL"); \ - return NS_ERROR_ABORT; \ - } \ - PR_END_MACRO - //---------------------------------------------------------------------------- // nsStandardURL::nsSegmentEncoder //---------------------------------------------------------------------------- @@ -181,7 +171,6 @@ nsStandardURL::nsStandardURL(bool aSupportsFileURL, bool aTrackURL) , mPort(-1) , mDisplayHost(nullptr) , mURLType(URLTYPE_STANDARD) - , mMutable(true) , mSupportsFileURL(aSupportsFileURL) , mCheckedIfHostA(false) { @@ -1205,7 +1194,6 @@ NS_INTERFACE_MAP_BEGIN(nsStandardURL) NS_INTERFACE_MAP_ENTRY(nsIStandardURL) NS_INTERFACE_MAP_ENTRY(nsISerializable) NS_INTERFACE_MAP_ENTRY(nsIClassInfo) - NS_INTERFACE_MAP_ENTRY(nsIMutable) NS_INTERFACE_MAP_ENTRY(nsIIPCSerializableURI) NS_INTERFACE_MAP_ENTRY(nsISensitiveInfoHiddenURI) // see nsStandardURL::Equals @@ -1502,8 +1490,6 @@ nsresult nsStandardURL::SetSpecWithEncoding(const nsACString &input, const Encoding* encoding) { - ENSURE_MUTABLE(); - const nsPromiseFlatCString &flat = PromiseFlatCString(input); LOG(("nsStandardURL::SetSpec [spec=%s]\n", flat.get())); @@ -1589,8 +1575,6 @@ nsStandardURL::SetSpecWithEncoding(const nsACString &input, nsresult nsStandardURL::SetScheme(const nsACString &input) { - ENSURE_MUTABLE(); - const nsPromiseFlatCString &scheme = PromiseFlatCString(input); LOG(("nsStandardURL::SetScheme [scheme=%s]\n", scheme.get())); @@ -1633,8 +1617,6 @@ nsStandardURL::SetScheme(const nsACString &input) nsresult nsStandardURL::SetUserPass(const nsACString &input) { - ENSURE_MUTABLE(); - const nsPromiseFlatCString &userpass = PromiseFlatCString(input); LOG(("nsStandardURL::SetUserPass [userpass=%s]\n", userpass.get())); @@ -1743,8 +1725,6 @@ nsStandardURL::SetUserPass(const nsACString &input) nsresult nsStandardURL::SetUsername(const nsACString &input) { - ENSURE_MUTABLE(); - const nsPromiseFlatCString &username = PromiseFlatCString(input); LOG(("nsStandardURL::SetUsername [username=%s]\n", username.get())); @@ -1793,8 +1773,6 @@ nsStandardURL::SetUsername(const nsACString &input) nsresult nsStandardURL::SetPassword(const nsACString &input) { - ENSURE_MUTABLE(); - const nsPromiseFlatCString &password = PromiseFlatCString(input); auto clearedPassword = MakeScopeExit([&password, this]() { @@ -1881,8 +1859,6 @@ nsStandardURL::FindHostLimit(nsACString::const_iterator& aStart, nsresult nsStandardURL::SetHostPort(const nsACString &aValue) { - ENSURE_MUTABLE(); - // We cannot simply call nsIURI::SetHost because that would treat the name as // an IPv6 address (like http:://[server:443]/). We also cannot call // nsIURI::SetHostPort because that isn't implemented. Sadfaces. @@ -1950,8 +1926,6 @@ nsStandardURL::SetHostPort(const nsACString &aValue) nsresult nsStandardURL::SetHost(const nsACString &input) { - ENSURE_MUTABLE(); - const nsPromiseFlatCString &hostname = PromiseFlatCString(input); nsACString::const_iterator start, end; @@ -2058,8 +2032,6 @@ nsStandardURL::SetHost(const nsACString &input) nsresult nsStandardURL::SetPort(int32_t port) { - ENSURE_MUTABLE(); - LOG(("nsStandardURL::SetPort [port=%d]\n", port)); if ((port == mPort) || (mPort == -1 && port == mDefaultPort)) @@ -2097,7 +2069,6 @@ nsStandardURL::SetPort(int32_t port) void nsStandardURL::ReplacePortInSpec(int32_t aNewPort) { - MOZ_ASSERT(mMutable, "Caller should ensure we're mutable"); NS_ASSERTION(aNewPort != mDefaultPort || mDefaultPort == -1, "Caller should check its passed-in value and pass -1 instead of " "mDefaultPort, to avoid encoding default port into mSpec"); @@ -2132,8 +2103,6 @@ nsStandardURL::ReplacePortInSpec(int32_t aNewPort) nsresult nsStandardURL::SetPathQueryRef(const nsACString &input) { - ENSURE_MUTABLE(); - const nsPromiseFlatCString &path = PromiseFlatCString(input); LOG(("nsStandardURL::SetPathQueryRef [path=%s]\n", path.get())); @@ -2363,7 +2332,6 @@ nsresult nsStandardURL::CopyMembers(nsStandardURL * source, mRef = source->mRef; mURLType = source->mURLType; mParser = source->mParser; - mMutable = true; mSupportsFileURL = source->mSupportsFileURL; mCheckedIfHostA = source->mCheckedIfHostA; mDisplayHost = source->mDisplayHost; @@ -2780,8 +2748,6 @@ nsStandardURL::GetFileExtension(nsACString &result) nsresult nsStandardURL::SetFilePath(const nsACString &input) { - ENSURE_MUTABLE(); - const nsPromiseFlatCString &flat = PromiseFlatCString(input); const char *filepath = flat.get(); @@ -2873,8 +2839,6 @@ nsresult nsStandardURL::SetQueryWithEncoding(const nsACString &input, const Encoding* encoding) { - ENSURE_MUTABLE(); - const nsPromiseFlatCString &flat = PromiseFlatCString(input); const char *query = flat.get(); @@ -2949,8 +2913,6 @@ nsStandardURL::SetQueryWithEncoding(const nsACString &input, nsresult nsStandardURL::SetRef(const nsACString &input) { - ENSURE_MUTABLE(); - const nsPromiseFlatCString &flat = PromiseFlatCString(input); const char *ref = flat.get(); @@ -3012,8 +2974,6 @@ nsStandardURL::SetRef(const nsACString &input) nsresult nsStandardURL::SetFileNameInternal(const nsACString &input) { - ENSURE_MUTABLE(); - const nsPromiseFlatCString &flat = PromiseFlatCString(input); const char *filename = flat.get(); @@ -3196,8 +3156,6 @@ nsStandardURL::GetFile(nsIFile **result) nsresult nsStandardURL::SetFile(nsIFile *file) { - ENSURE_MUTABLE(); - NS_ENSURE_ARG_POINTER(file); nsresult rv; @@ -3239,8 +3197,6 @@ nsStandardURL::Init(uint32_t urlType, const char *charset, nsIURI *baseURI) { - ENSURE_MUTABLE(); - if (spec.Length() > (uint32_t) net_GetURLMaxLength() || defaultPort > std::numeric_limits::max()) { return NS_ERROR_MALFORMED_URI; @@ -3292,8 +3248,6 @@ nsStandardURL::Init(uint32_t urlType, nsresult nsStandardURL::SetDefaultPort(int32_t aNewDefaultPort) { - ENSURE_MUTABLE(); - InvalidateCache(); // should never be more than 16 bit @@ -3313,22 +3267,6 @@ nsStandardURL::SetDefaultPort(int32_t aNewDefaultPort) return NS_OK; } -NS_IMETHODIMP -nsStandardURL::GetMutable(bool *value) -{ - *value = mMutable; - return NS_OK; -} - -NS_IMETHODIMP -nsStandardURL::SetMutable(bool value) -{ - NS_ENSURE_ARG(mMutable || !value); - - mMutable = value; - return NS_OK; -} - //---------------------------------------------------------------------------- // nsStandardURL::nsISerializable //---------------------------------------------------------------------------- @@ -3423,7 +3361,7 @@ nsStandardURL::ReadPrivate(nsIObjectInputStream *stream) bool isMutable; rv = stream->ReadBoolean(&isMutable); if (NS_FAILED(rv)) return rv; - mMutable = isMutable; + Unused << isMutable; bool supportsFileURL; rv = stream->ReadBoolean(&supportsFileURL); @@ -3517,7 +3455,8 @@ nsStandardURL::Write(nsIObjectOutputStream *stream) rv = NS_WriteOptionalStringZ(stream, EmptyCString().get()); if (NS_FAILED(rv)) return rv; - rv = stream->WriteBoolean(mMutable); + // former mMutable + rv = stream->WriteBoolean(false); if (NS_FAILED(rv)) return rv; rv = stream->WriteBoolean(mSupportsFileURL); @@ -3588,7 +3527,6 @@ nsStandardURL::Serialize(URIParams& aParams) params.extension() = ToIPCSegment(mExtension); params.query() = ToIPCSegment(mQuery); params.ref() = ToIPCSegment(mRef); - params.isMutable() = !!mMutable; params.supportsFileURL() = !!mSupportsFileURL; // mDisplayHost is just a cache that can be recovered as needed. @@ -3641,7 +3579,6 @@ nsStandardURL::Deserialize(const URIParams& aParams) NS_ENSURE_TRUE(FromIPCSegment(mSpec, params.query(), mQuery), false); NS_ENSURE_TRUE(FromIPCSegment(mSpec, params.ref(), mRef), false); - mMutable = params.isMutable(); mSupportsFileURL = params.supportsFileURL(); nsresult rv = CheckIfHostIsAscii(); diff --git a/netwerk/base/nsStandardURL.h b/netwerk/base/nsStandardURL.h index ec052d67a5da..a5cf522cbdfa 100644 --- a/netwerk/base/nsStandardURL.h +++ b/netwerk/base/nsStandardURL.h @@ -65,7 +65,6 @@ public: NS_DECL_NSISTANDARDURL NS_DECL_NSISERIALIZABLE NS_DECL_NSICLASSINFO - NS_DECL_NSIMUTABLE NS_DECL_NSIIPCSERIALIZABLEURI NS_DECL_NSISENSITIVEINFOHIDDENURI @@ -300,7 +299,6 @@ private: }; uint32_t mURLType : 2; // nsIStandardURL::URLTYPE_xxx - uint32_t mMutable : 1; // nsIStandardURL::mutable uint32_t mSupportsFileURL : 1; // QI to nsIFileURL? uint32_t mCheckedIfHostA : 1; // If set to true, it means either that // mDisplayHost has a been initialized, or diff --git a/netwerk/protocol/about/nsAboutProtocolHandler.cpp b/netwerk/protocol/about/nsAboutProtocolHandler.cpp index 150d8aed84d4..55780b2e46c9 100644 --- a/netwerk/protocol/about/nsAboutProtocolHandler.cpp +++ b/netwerk/protocol/about/nsAboutProtocolHandler.cpp @@ -160,9 +160,6 @@ nsAboutProtocolHandler::NewURI(const nsACString &aSpec, NS_ENSURE_SUCCESS(rv, rv); } - // We don't want to allow mutation, since it would allow safe and - // unsafe URIs to change into each other... - NS_TryToSetImmutable(url); url.swap(*result); return NS_OK; } @@ -325,7 +322,6 @@ nsSafeAboutProtocolHandler::NewURI(const nsACString &aSpec, return rv; } - NS_TryToSetImmutable(*result); return NS_OK; } @@ -444,7 +440,6 @@ nsNestedAboutURI::StartClone(nsSimpleURI::RefHandlingEnum aRefHandlingMode, nsNestedAboutURI* url = new nsNestedAboutURI(innerClone, mBaseURI); SetRefOnClone(url, aRefHandlingMode, aNewRef); - url->SetMutable(false); return url; } @@ -464,9 +459,6 @@ nsNestedAboutURI::Mutate(nsIURIMutator** aMutator) if (NS_FAILED(rv)) { return rv; } - // StartClone calls SetMutable(false) but we need the mutator clone - // to be mutable - mutator->ResetMutable(); mutator.forget(aMutator); return NS_OK; } diff --git a/netwerk/protocol/viewsource/nsViewSourceHandler.cpp b/netwerk/protocol/viewsource/nsViewSourceHandler.cpp index 5300d4a35f8e..6c6a7a6a3d26 100644 --- a/netwerk/protocol/viewsource/nsViewSourceHandler.cpp +++ b/netwerk/protocol/viewsource/nsViewSourceHandler.cpp @@ -105,10 +105,6 @@ nsViewSourceHandler::NewURI(const nsACString &aSpec, return rv; } - // Make the URI immutable so it's impossible to get it out of sync - // with its inner URI. - NS_TryToSetImmutable(uri); - uri.swap(*aResult); return rv; } diff --git a/netwerk/test/unit/test_1351443-missing-NewChannel2.js b/netwerk/test/unit/test_1351443-missing-NewChannel2.js index 73ed4c41f99e..0e9df0d79a21 100644 --- a/netwerk/test/unit/test_1351443-missing-NewChannel2.js +++ b/netwerk/test/unit/test_1351443-missing-NewChannel2.js @@ -17,7 +17,6 @@ function ProtocolHandler() { .createInstance(Ci.nsIURIMutator) .setSpec(this.scheme + ":dummy") .finalize(); - this.uri.QueryInterface(Ci.nsIMutable).mutable = false; } ProtocolHandler.prototype = { diff --git a/netwerk/test/unit/test_bug894586.js b/netwerk/test/unit/test_bug894586.js index ccec4ed538c7..5d53e757c5d1 100644 --- a/netwerk/test/unit/test_bug894586.js +++ b/netwerk/test/unit/test_bug894586.js @@ -15,7 +15,6 @@ function ProtocolHandler() { .createInstance(Ci.nsIURIMutator) .setSpec(this.scheme + ":dummy") .finalize(); - this.uri.QueryInterface(Ci.nsIMutable).mutable = false; } ProtocolHandler.prototype = {