Bug 1476928 - Remove nsIURI.CloneIgnoringRef and nsIURI.CloneWithNewRef r=JuniorHsu

The patch introduces NS_GetURIWithNewRef and NS_GetURIWithNewRef which perform the same function.

Differential Revision: https://phabricator.services.mozilla.com/D2239

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Valentin Gosu 2018-07-23 11:28:47 +00:00
Родитель 842fbbb159
Коммит 7937c7c4cc
37 изменённых файлов: 114 добавлений и 175 удалений

Просмотреть файл

@ -291,22 +291,6 @@ NullPrincipalURI::Clone(nsIURI** _newURI)
return NS_OK;
}
NS_IMETHODIMP
NullPrincipalURI::CloneIgnoringRef(nsIURI** _newURI)
{
// GetRef/SetRef not supported by NullPrincipalURI, so
// CloneIgnoringRef() is the same as Clone().
return Clone(_newURI);
}
NS_IMETHODIMP
NullPrincipalURI::CloneWithNewRef(const nsACString& newRef, nsIURI** _newURI)
{
// GetRef/SetRef not supported by NullPrincipalURI, so
// CloneWithNewRef() is the same as Clone().
return Clone(_newURI);
}
NS_IMPL_ISUPPORTS(NullPrincipalURI::Mutator, nsIURISetters, nsIURIMutator)
NS_IMETHODIMP

Просмотреть файл

@ -206,26 +206,6 @@ Location::GetURI(nsIURI** aURI, bool aGetInnermostURI)
return urifixup->CreateExposableURI(uri, aURI);
}
nsresult
Location::GetWritableURI(nsIURI** aURI, const nsACString* aNewRef)
{
*aURI = nullptr;
nsCOMPtr<nsIURI> uri;
nsresult rv = GetURI(getter_AddRefs(uri));
if (NS_FAILED(rv) || !uri) {
return rv;
}
if (!aNewRef) {
uri.forget(aURI);
return NS_OK;
}
return uri->CloneWithNewRef(*aNewRef, aURI);
}
nsresult
Location::SetURI(nsIURI* aURI, bool aReplace)
{
@ -313,7 +293,14 @@ Location::SetHash(const nsAString& aHash,
}
nsCOMPtr<nsIURI> uri;
aRv = GetWritableURI(getter_AddRefs(uri), &hash);
aRv = GetURI(getter_AddRefs(uri));
if (NS_WARN_IF(aRv.Failed()) || !uri) {
return;
}
aRv = NS_MutateURI(uri)
.SetRef(hash)
.Finalize(uri);
if (NS_WARN_IF(aRv.Failed()) || !uri) {
return;
}

Просмотреть файл

@ -166,11 +166,6 @@ protected:
// Note, this method can return NS_OK with a null value for aURL. This happens
// if the docShell is null.
nsresult GetURI(nsIURI** aURL, bool aGetInnermostURI = false);
// Note, this method can return NS_OK with a null value for aURL. This happens
// if the docShell is null.
nsresult GetWritableURI(nsIURI** aURL,
// If not null, give it the new ref
const nsACString* aNewRef = nullptr);
nsresult SetURI(nsIURI* aURL, bool aReplace = false);
nsresult SetHrefWithBase(const nsAString& aHref, nsIURI* aBase,
bool aReplace);

Просмотреть файл

@ -376,7 +376,7 @@ nsContentSink::LinkContextIsOurDocument(const nsAString& aAnchor)
// we want to ignore that because it's invisible to the server
// and just affects the local interpretation in the recipient
nsCOMPtr<nsIURI> contextUri;
nsresult rv = docUri->CloneIgnoringRef(getter_AddRefs(contextUri));
nsresult rv = NS_GetURIWithoutRef(docUri, getter_AddRefs(contextUri));
if (NS_FAILED(rv)) {
// copying failed

Просмотреть файл

@ -827,7 +827,7 @@ nsExternalResourceMap::RequestResource(nsIURI* aURI,
// First, make sure we strip the ref from aURI.
nsCOMPtr<nsIURI> clone;
nsresult rv = aURI->CloneIgnoringRef(getter_AddRefs(clone));
nsresult rv = NS_GetURIWithoutRef(aURI, getter_AddRefs(clone));
if (NS_FAILED(rv) || !clone) {
return nullptr;
}

Просмотреть файл

@ -1283,7 +1283,7 @@ nsGlobalWindowOuter::WouldReuseInnerWindow(nsIDocument* aNewDocument)
#ifdef DEBUG
{
nsCOMPtr<nsIURI> uri;
mDoc->GetDocumentURI()->CloneIgnoringRef(getter_AddRefs(uri));
NS_GetURIWithoutRef(mDoc->GetDocumentURI(), getter_AddRefs(uri));
NS_ASSERTION(NS_IsAboutBlank(uri), "How'd this happen?");
}
#endif

Просмотреть файл

@ -1287,7 +1287,7 @@ FetchDriver::AsyncOnChannelRedirect(nsIChannel* aOldChannel,
MOZ_ALWAYS_SUCCEEDS(aNewChannel->GetURI(getter_AddRefs(uri)));
nsCOMPtr<nsIURI> uriClone;
nsresult rv = uri->CloneIgnoringRef(getter_AddRefs(uriClone));
nsresult rv = NS_GetURIWithoutRef(uri, getter_AddRefs(uriClone));
if(NS_WARN_IF(NS_FAILED(rv))){
return rv;
}

Просмотреть файл

@ -117,9 +117,7 @@ GetRequestURLFromDocument(nsIDocument* aDocument, const nsAString& aInput,
}
nsCOMPtr<nsIURI> resolvedURIClone;
// We use CloneIgnoringRef to strip away the fragment even if the original URI
// is immutable.
aRv = resolvedURI->CloneIgnoringRef(getter_AddRefs(resolvedURIClone));
aRv = NS_GetURIWithoutRef(resolvedURI, getter_AddRefs(resolvedURIClone));
if (NS_WARN_IF(aRv.Failed())) {
return;
}
@ -165,9 +163,7 @@ GetRequestURLFromChrome(const nsAString& aInput, nsAString& aRequestURL,
}
nsCOMPtr<nsIURI> uriClone;
// We use CloneIgnoringRef to strip away the fragment even if the original URI
// is immutable.
aRv = uri->CloneIgnoringRef(getter_AddRefs(uriClone));
aRv = NS_GetURIWithoutRef(uri, getter_AddRefs(uriClone));
if (NS_WARN_IF(aRv.Failed())) {
return;
}

Просмотреть файл

@ -1518,7 +1518,7 @@ nsCSPContext::PermitsAncestry(nsIDocShell* aDocShell, bool* outPermitsAncestry)
// If setUserPass fails for some reason, just return a clone of the
// current URI
if (NS_FAILED(rv)) {
rv = currentURI->CloneIgnoringRef(getter_AddRefs(uriClone));
rv = NS_GetURIWithoutRef(currentURI, getter_AddRefs(uriClone));
NS_ENSURE_SUCCESS(rv, rv);
}

Просмотреть файл

@ -254,13 +254,13 @@ ServiceWorkerContainer::Register(const nsAString& aScriptURL,
// Strip the any ref from both the script and scope URLs.
nsCOMPtr<nsIURI> cloneWithoutRef;
aRv = scriptURI->CloneIgnoringRef(getter_AddRefs(cloneWithoutRef));
aRv = NS_GetURIWithoutRef(scriptURI, getter_AddRefs(cloneWithoutRef));
if (aRv.Failed()) {
return nullptr;
}
scriptURI = cloneWithoutRef.forget();
aRv = scopeURI->CloneIgnoringRef(getter_AddRefs(cloneWithoutRef));
aRv = NS_GetURIWithoutRef(scopeURI, getter_AddRefs(cloneWithoutRef));
if (aRv.Failed()) {
return nullptr;
}

Просмотреть файл

@ -1368,7 +1368,7 @@ public:
// fragment manually here instead. We can't do it later when we create
// the Request because that code executes off the main thread.
nsCOMPtr<nsIURI> uriNoFragment;
rv = uri->CloneIgnoringRef(getter_AddRefs(uriNoFragment));
rv = NS_GetURIWithoutRef(uri, getter_AddRefs(uriNoFragment));
NS_ENSURE_SUCCESS(rv, rv);
rv = uriNoFragment->GetSpec(mSpec);
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -915,7 +915,7 @@ nsXBLService::LoadBindingDocumentInfo(nsIContent* aBoundElement,
RefPtr<nsXBLDocumentInfo> info;
nsCOMPtr<nsIURI> documentURI;
nsresult rv = aBindingURI->CloneIgnoringRef(getter_AddRefs(documentURI));
nsresult rv = NS_GetURIWithoutRef(aBindingURI, getter_AddRefs(documentURI));
NS_ENSURE_SUCCESS(rv, rv);
nsBindingManager *bindingManager = nullptr;

Просмотреть файл

@ -688,7 +688,7 @@ TX_CompileStylesheet(nsINode* aNode, txMozillaXSLTProcessor* aProcessor,
// We need to remove the ref, a URI with a ref would mean that we have an
// embedded stylesheet.
docUri->CloneIgnoringRef(getter_AddRefs(uri));
NS_GetURIWithoutRef(docUri, getter_AddRefs(uri));
NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
uri->GetSpec(spec);

Просмотреть файл

@ -143,7 +143,7 @@ nsXULPrototypeCache::GetPrototype(nsIURI* aURI)
return nullptr;
nsCOMPtr<nsIURI> uriWithoutRef;
aURI->CloneIgnoringRef(getter_AddRefs(uriWithoutRef));
NS_GetURIWithoutRef(aURI, getter_AddRefs(uriWithoutRef));
nsXULPrototypeDocument* protoDoc = mPrototypeTable.GetWeak(uriWithoutRef);
if (protoDoc)
@ -183,7 +183,7 @@ nsXULPrototypeCache::PutPrototype(nsXULPrototypeDocument* aDocument)
}
nsCOMPtr<nsIURI> uri;
aDocument->GetURI()->CloneIgnoringRef(getter_AddRefs(uri));
NS_GetURIWithoutRef(aDocument->GetURI(), getter_AddRefs(uri));
// Put() releases any old value and addrefs the new one
mPrototypeTable.Put(uri, aDocument);

Просмотреть файл

@ -534,23 +534,6 @@ nsMozIconURI::Clone(nsIURI** result)
return NS_OK;
}
NS_IMETHODIMP
nsMozIconURI::CloneIgnoringRef(nsIURI** result)
{
// GetRef/SetRef not supported by nsMozIconURI, so
// CloneIgnoringRef() is the same as Clone().
return Clone(result);
}
NS_IMETHODIMP
nsMozIconURI::CloneWithNewRef(const nsACString& newRef, nsIURI** result)
{
// GetRef/SetRef not supported by nsMozIconURI, so
// CloneWithNewRef() is the same as Clone().
return Clone(result);
}
NS_IMETHODIMP
nsMozIconURI::Resolve(const nsACString& relativePath, nsACString& result)
{

Просмотреть файл

@ -603,33 +603,6 @@ nsJARURI::Clone(nsIURI **result)
return NS_OK;
}
NS_IMETHODIMP
nsJARURI::CloneIgnoringRef(nsIURI **result)
{
nsresult rv;
nsCOMPtr<nsIJARURI> uri;
rv = CloneWithJARFileInternal(mJARFile, eIgnoreRef, getter_AddRefs(uri));
if (NS_FAILED(rv)) return rv;
uri.forget(result);
return NS_OK;
}
NS_IMETHODIMP
nsJARURI::CloneWithNewRef(const nsACString& newRef, nsIURI **result)
{
nsresult rv;
nsCOMPtr<nsIJARURI> uri;
rv = CloneWithJARFileInternal(mJARFile, eReplaceRef, newRef,
getter_AddRefs(uri));
if (NS_FAILED(rv)) return rv;
uri.forget(result);
return NS_OK;
}
NS_IMETHODIMP
nsJARURI::Resolve(const nsACString &relativePath, nsACString &result)
{
@ -916,9 +889,9 @@ nsJARURI::CloneWithJARFileInternal(nsIURI *jarFile,
if (refHandlingMode == eHonorRef) {
newJAREntryURI = mJAREntry;
} else if (refHandlingMode == eReplaceRef) {
rv = mJAREntry->CloneWithNewRef(newRef, getter_AddRefs(newJAREntryURI));
rv = NS_GetURIWithNewRef(mJAREntry, newRef, getter_AddRefs(newJAREntryURI));
} else {
rv = mJAREntry->CloneIgnoringRef(getter_AddRefs(newJAREntryURI));
rv = NS_GetURIWithoutRef(mJAREntry, getter_AddRefs(newJAREntryURI));
}
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -687,7 +687,7 @@ nsIOService::NewURI(const nsACString &aSpec, const char *aCharset, nsIURI *aBase
if (!aSpec.IsEmpty() && aSpec[0] == '#') {
// Looks like a reference instead of a fully-specified URI.
// --> initialize |uri| as a clone of |aBaseURI|, with ref appended.
return aBaseURI->CloneWithNewRef(aSpec, result);
return NS_GetURIWithNewRef(aBaseURI, aSpec, result);
}
rv = aBaseURI->GetScheme(scheme);

Просмотреть файл

@ -236,17 +236,6 @@ interface nsIURI : nsISupports
*/
boolean equalsExceptRef(in nsIURI other);
/**
* Clones the current URI, clearing the 'ref' attribute in the clone.
*/
nsIURI cloneIgnoringRef();
/**
* Clones the current URI, replacing the 'ref' attribute in the clone with
* the ref supplied.
*/
nsIURI cloneWithNewRef(in AUTF8String newRef);
/**
* returns a string for the current URI with the ref element cleared.
*/

Просмотреть файл

@ -163,6 +163,47 @@ NS_NewFileURI(nsIURI **result,
return rv;
}
nsresult
NS_GetURIWithNewRef(nsIURI* aInput,
const nsACString& aRef,
nsIURI** aOutput)
{
if (NS_WARN_IF(!aInput || !aOutput)) {
return NS_ERROR_INVALID_ARG;
}
bool hasRef;
nsresult rv = aInput->GetHasRef(&hasRef);
nsAutoCString ref;
if (NS_SUCCEEDED(rv)) {
rv = aInput->GetRef(ref);
}
// If the ref is already equal to the new ref, we do not need to do anything.
// Also, if the GetRef failed (it could return NS_ERROR_NOT_IMPLEMENTED)
// we can assume SetRef would fail as well, so returning the original
// URI is OK.
if (NS_FAILED(rv) ||
(!hasRef && aRef.IsEmpty()) ||
(!aRef.IsEmpty() && aRef == ref)) {
nsCOMPtr<nsIURI> uri = aInput;
uri.forget(aOutput);
return NS_OK;
}
return NS_MutateURI(aInput)
.SetRef(aRef)
.Finalize(aOutput);
}
nsresult
NS_GetURIWithoutRef(nsIURI* aInput,
nsIURI** aOutput)
{
return NS_GetURIWithNewRef(aInput, EmptyCString(), aOutput);
}
nsresult
NS_NewChannelInternal(nsIChannel **outChannel,
nsIURI *aUri,

Просмотреть файл

@ -103,6 +103,19 @@ nsresult NS_NewFileURI(nsIURI **result,
nsIFile *spec,
nsIIOService *ioService = nullptr); // pass in nsIIOService to optimize callers
// These methods will only mutate the URI if the ref of aInput doesn't already
// match the ref we are trying to set.
// If aInput has no ref, and we are calling NS_GetURIWithoutRef, or
// NS_GetURIWithNewRef with an empty string, then aOutput will be the same
// as aInput. The same is true if aRef is already equal to the ref of aInput.
// This is OK because URIs are immutable and threadsafe.
// If the URI doesn't support ref fragments aOutput will be the same as aInput.
nsresult NS_GetURIWithNewRef(nsIURI* aInput,
const nsACString& aRef,
nsIURI** aOutput);
nsresult NS_GetURIWithoutRef(nsIURI* aInput,
nsIURI** aOutput);
nsresult NS_GetSanitizedURIStringFromURI(nsIURI *aUri,
nsAString &aSanitizedSpec);

Просмотреть файл

@ -212,9 +212,9 @@ nsSimpleNestedURI::StartClone(nsSimpleURI::RefHandlingEnum refHandlingMode,
if (refHandlingMode == eHonorRef) {
innerClone = mInnerURI;
} else if (refHandlingMode == eReplaceRef) {
rv = mInnerURI->CloneWithNewRef(newRef, getter_AddRefs(innerClone));
rv = NS_GetURIWithNewRef(mInnerURI, newRef, getter_AddRefs(innerClone));
} else {
rv = mInnerURI->CloneIgnoringRef(getter_AddRefs(innerClone));
rv = NS_GetURIWithoutRef(mInnerURI, getter_AddRefs(innerClone));
}
if (NS_FAILED(rv)) {

Просмотреть файл

@ -633,18 +633,6 @@ nsSimpleURI::Clone(nsIURI** result)
return CloneInternal(eHonorRef, EmptyCString(), result);
}
NS_IMETHODIMP
nsSimpleURI::CloneIgnoringRef(nsIURI** result)
{
return CloneInternal(eIgnoreRef, EmptyCString(), result);
}
NS_IMETHODIMP
nsSimpleURI::CloneWithNewRef(const nsACString &newRef, nsIURI** result)
{
return CloneInternal(eReplaceRef, newRef, result);
}
nsresult
nsSimpleURI::CloneInternal(nsSimpleURI::RefHandlingEnum refHandlingMode,
const nsACString &newRef,

Просмотреть файл

@ -2279,19 +2279,6 @@ nsStandardURL::Clone(nsIURI **result)
return CloneInternal(eHonorRef, EmptyCString(), result);
}
NS_IMETHODIMP
nsStandardURL::CloneIgnoringRef(nsIURI **result)
{
return CloneInternal(eIgnoreRef, EmptyCString(), result);
}
NS_IMETHODIMP
nsStandardURL::CloneWithNewRef(const nsACString& newRef, nsIURI **result)
{
return CloneInternal(eReplaceRef, newRef, result);
}
nsresult
nsStandardURL::CloneInternal(nsStandardURL::RefHandlingEnum refHandlingMode,
const nsACString& newRef,

4
netwerk/cache/nsDiskCacheDeviceSQL.cpp поставляемый
Просмотреть файл

@ -752,7 +752,7 @@ nsApplicationCache::GetManifestURI(nsIURI **out)
nsresult rv = NS_NewURI(getter_AddRefs(uri), mGroup);
NS_ENSURE_SUCCESS(rv, rv);
rv = uri->CloneIgnoringRef(out);
rv = NS_GetURIWithNewRef(uri, EmptyCString(), out);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
@ -1372,7 +1372,7 @@ nsOfflineCacheDevice::BuildApplicationCacheGroupID(nsIURI *aManifestURL,
nsACString &_result)
{
nsCOMPtr<nsIURI> newURI;
nsresult rv = aManifestURL->CloneIgnoringRef(getter_AddRefs(newURI));
nsresult rv = NS_GetURIWithNewRef(aManifestURL, EmptyCString(), getter_AddRefs(newURI));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString manifestSpec;

Просмотреть файл

@ -15,6 +15,7 @@
#include "nsIApplicationCacheService.h"
#include "nsIURI.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include "nsServiceManagerUtils.h"
#include "nsThreadUtils.h"
@ -60,7 +61,7 @@ NS_IMETHODIMP AppCacheStorage::AsyncOpenURI(nsIURI *aURI,
}
nsCOMPtr<nsIURI> noRefURI;
rv = aURI->CloneIgnoringRef(getter_AddRefs(noRefURI));
rv = NS_GetURIWithoutRef(aURI, getter_AddRefs(noRefURI));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString cacheKey;

Просмотреть файл

@ -16,6 +16,7 @@
#include "nsIApplicationCacheService.h"
#include "nsIURI.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include "nsServiceManagerUtils.h"
namespace mozilla {
@ -64,7 +65,7 @@ NS_IMETHODIMP CacheStorage::AsyncOpenURI(nsIURI *aURI,
bool truncate = aFlags & nsICacheStorage::OPEN_TRUNCATE;
nsCOMPtr<nsIURI> noRefURI;
rv = aURI->CloneIgnoringRef(getter_AddRefs(noRefURI));
rv = NS_GetURIWithoutRef(aURI, getter_AddRefs(noRefURI));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString asciiSpec;
@ -120,7 +121,7 @@ NS_IMETHODIMP CacheStorage::OpenTruncate(nsIURI *aURI, const nsACString & aIdExt
nsresult rv;
nsCOMPtr<nsIURI> noRefURI;
rv = aURI->CloneIgnoringRef(getter_AddRefs(noRefURI));
rv = NS_GetURIWithoutRef(aURI, getter_AddRefs(noRefURI));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString asciiSpec;
@ -156,7 +157,7 @@ NS_IMETHODIMP CacheStorage::Exists(nsIURI *aURI, const nsACString & aIdExtension
nsresult rv;
nsCOMPtr<nsIURI> noRefURI;
rv = aURI->CloneIgnoringRef(getter_AddRefs(noRefURI));
rv = NS_GetURIWithoutRef(aURI, getter_AddRefs(noRefURI));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString asciiSpec;
@ -183,7 +184,7 @@ CacheStorage::GetCacheIndexEntryAttrs(nsIURI *aURI,
nsresult rv;
nsCOMPtr<nsIURI> noRefURI;
rv = aURI->CloneIgnoringRef(getter_AddRefs(noRefURI));
rv = NS_GetURIWithoutRef(aURI, getter_AddRefs(noRefURI));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString asciiSpec;
@ -203,7 +204,7 @@ NS_IMETHODIMP CacheStorage::AsyncDoomURI(nsIURI *aURI, const nsACString & aIdExt
nsresult rv;
nsCOMPtr<nsIURI> noRefURI;
rv = aURI->CloneIgnoringRef(getter_AddRefs(noRefURI));
rv = NS_GetURIWithoutRef(aURI, getter_AddRefs(noRefURI));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString asciiSpec;

Просмотреть файл

@ -1112,7 +1112,7 @@ nsresult _OldStorage::AssembleCacheKey(nsIURI *aURI,
}
nsCOMPtr<nsIURI> noRefURI;
rv = aURI->CloneIgnoringRef(getter_AddRefs(noRefURI));
rv = NS_GetURIWithoutRef(aURI, getter_AddRefs(noRefURI));
NS_ENSURE_SUCCESS(rv, rv);
rv = noRefURI->GetAsciiSpec(uriSpec);

Просмотреть файл

@ -429,9 +429,9 @@ nsNestedAboutURI::StartClone(nsSimpleURI::RefHandlingEnum aRefHandlingMode,
if (aRefHandlingMode == eHonorRef) {
innerClone = mInnerURI;
} else if (aRefHandlingMode == eReplaceRef) {
rv = mInnerURI->CloneWithNewRef(aNewRef, getter_AddRefs(innerClone));
rv = NS_GetURIWithNewRef(mInnerURI, aNewRef, getter_AddRefs(innerClone));
} else {
rv = mInnerURI->CloneIgnoringRef(getter_AddRefs(innerClone));
rv = NS_GetURIWithoutRef(mInnerURI, getter_AddRefs(innerClone));
}
if (NS_FAILED(rv)) {

Просмотреть файл

@ -53,7 +53,7 @@ nsDataChannel::OpenContentStream(bool async, nsIInputStream **result,
// of the URI that does not have a ref and in most cases should share
// string buffers with the original URI.
nsCOMPtr<nsIURI> uri;
rv = URI()->CloneIgnoringRef(getter_AddRefs(uri));
rv = NS_GetURIWithoutRef(URI(), getter_AddRefs(uri));
if (NS_FAILED(rv))
return rv;

Просмотреть файл

@ -1788,9 +1788,9 @@ HttpBaseChannel::SetReferrerWithPolicy(nsIURI *referrer,
// (1) modify it
// (2) keep a reference to it after returning from this function
//
// Use CloneIgnoringRef to strip away any fragment per RFC 2616 section 14.36
// Strip away any fragment per RFC 2616 section 14.36
// and Referrer Policy section 6.3.5.
rv = referrer->CloneIgnoringRef(getter_AddRefs(clone));
rv = NS_GetURIWithoutRef(referrer, getter_AddRefs(clone));
if (NS_FAILED(rv)) return rv;
nsAutoCString currentHost;
@ -1835,7 +1835,7 @@ HttpBaseChannel::SetReferrerWithPolicy(nsIURI *referrer,
// send spoofed referrer if desired
if (userSpoofReferrerSource) {
nsCOMPtr<nsIURI> mURIclone;
rv = mURI->CloneIgnoringRef(getter_AddRefs(mURIclone));
rv = NS_GetURIWithoutRef(mURI, getter_AddRefs(mURIclone));
if (NS_FAILED(rv)) return rv;
clone = mURIclone;
currentHost = referrerHost;

Просмотреть файл

@ -8186,7 +8186,7 @@ nsHttpChannel::OfflineCacheEntryAsForeignMarker::MarkAsForeign()
nsresult rv;
nsCOMPtr<nsIURI> noRefURI;
rv = mCacheURI->CloneIgnoringRef(getter_AddRefs(noRefURI));
rv = NS_GetURIWithoutRef(mCacheURI, getter_AddRefs(noRefURI));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString spec;

Просмотреть файл

@ -339,7 +339,7 @@ function do_test_uri_basic(aTest) {
// Sanity-check
do_info("testing " + aTest.spec + " equals a clone of itself");
do_check_uri_eq(URI, URI.mutate().finalize());
do_check_uri_eqExceptRef(URI, URI.cloneIgnoringRef());
do_check_uri_eqExceptRef(URI, URI.mutate().setRef("").finalize());
do_info("testing " + aTest.spec + " instanceof nsIURL");
Assert.equal(URI instanceof Ci.nsIURL, aTest.nsIURL);
do_info("testing " + aTest.spec + " instanceof nsINestedURI");
@ -419,22 +419,24 @@ function do_test_uri_with_hash_suffix(aTest, aSuffix) {
if (!origURI.ref) {
// These tests fail if origURI has a ref
do_info("testing cloneIgnoringRef on " + testURI.spec +
do_info("testing setRef('') on " + testURI.spec +
" is equal to no-ref version but not equal to ref version");
var cloneNoRef = testURI.cloneIgnoringRef();
var cloneNoRef = testURI.mutate().setRef("").finalize(); // we used to clone here.
do_info("cloneNoRef: " + cloneNoRef.spec + " hasRef: " + cloneNoRef.hasRef);
do_info("testURI: " + testURI.spec + " hasRef: " + testURI.hasRef);
do_check_uri_eq(cloneNoRef, origURI);
Assert.ok(!cloneNoRef.equals(testURI));
do_info("testing cloneWithNewRef on " + testURI.spec +
" with an empty ref is equal to no-ref version but not equal to ref version");
var cloneNewRef = testURI.cloneWithNewRef("");
var cloneNewRef = testURI.mutate().setRef("").finalize();
do_check_uri_eq(cloneNewRef, origURI);
do_check_uri_eq(cloneNewRef, cloneNoRef);
Assert.ok(!cloneNewRef.equals(testURI));
do_info("testing cloneWithNewRef on " + origURI.spec +
" with the same new ref is equal to ref version and not equal to no-ref version");
cloneNewRef = origURI.cloneWithNewRef(aSuffix);
cloneNewRef = origURI.mutate().setRef(aSuffix).finalize();
do_check_uri_eq(cloneNewRef, testURI);
Assert.ok(cloneNewRef.equals(testURI));
}

Просмотреть файл

@ -448,7 +448,7 @@ function do_test_uri_basic(aTest) {
// Sanity-check
do_info("testing " + aTest.spec + " equals a clone of itself");
do_check_uri_eq(URI, URI.mutate().finalize());
do_check_uri_eqExceptRef(URI, URI.cloneIgnoringRef());
do_check_uri_eqExceptRef(URI, URI.mutate().setRef("").finalize());
do_info("testing " + aTest.spec + " instanceof nsIURL");
Assert.equal(URI instanceof Ci.nsIURL, aTest.nsIURL);
do_info("testing " + aTest.spec + " instanceof nsINestedURI");
@ -530,7 +530,7 @@ function do_test_uri_with_hash_suffix(aTest, aSuffix) {
// These tests fail if origURI has a ref
do_info("testing cloneIgnoringRef on " + testURI.spec +
" is equal to no-ref version but not equal to ref version");
var cloneNoRef = testURI.cloneIgnoringRef();
var cloneNoRef = testURI.mutate().setRef("").finalize();
do_check_uri_eq(cloneNoRef, origURI);
Assert.ok(!cloneNoRef.equals(testURI));
}

Просмотреть файл

@ -470,7 +470,7 @@ ProxyMessenger = {
// connected to the tab's top-level message manager. To deal with
// this, we find the options <browser> for the tab, and use that
// directly, insteead.
if (browser.currentURI.cloneIgnoringRef().spec === "about:addons") {
if (browser.currentURI.specIgnoringRef === "about:addons") {
let optionsBrowser = browser.contentDocument.querySelector(".inline-options-browser");
if (optionsBrowser) {
browser = optionsBrowser;

Просмотреть файл

@ -327,7 +327,7 @@ ExtensionPolicyService::CheckWindow(nsPIDOMWindowOuter* aWindow)
nsCOMPtr<nsIURI> docUri = doc->GetDocumentURI();
nsCOMPtr<nsIURI> uri;
if (!docUri || NS_FAILED(docUri->CloneIgnoringRef(getter_AddRefs(uri))) ||
if (!docUri || NS_FAILED(NS_GetURIWithoutRef(docUri, getter_AddRefs(uri))) ||
!NS_IsAboutBlank(uri)) {
return;
}

Просмотреть файл

@ -189,7 +189,7 @@ nsIURI*
URLInfo::URINoRef() const
{
if (!mURINoRef) {
if (NS_FAILED(mURI->CloneIgnoringRef(getter_AddRefs(mURINoRef)))) {
if (NS_FAILED(NS_GetURIWithoutRef(mURI, getter_AddRefs(mURINoRef)))) {
mURINoRef = mURI;
}
}

Просмотреть файл

@ -86,9 +86,8 @@ DropReferenceFromURL(nsCOMPtr<nsIURI>& aURI)
{
// XXXdholbert If this SetRef fails, callers of this method probably
// want to call aURI->CloneIgnoringRef() and use the result of that.
return NS_MutateURI(aURI)
.SetRef(EmptyCString())
.Finalize(aURI);
nsCOMPtr<nsIURI> uri(aURI);
return NS_GetURIWithoutRef(uri, getter_AddRefs(aURI));
}
void
@ -1247,7 +1246,7 @@ nsOfflineCacheUpdate::GetCacheKey(nsIURI *aURI, nsACString &aKey)
aKey.Truncate();
nsCOMPtr<nsIURI> newURI;
nsresult rv = aURI->CloneIgnoringRef(getter_AddRefs(newURI));
nsresult rv = NS_GetURIWithoutRef(aURI, getter_AddRefs(newURI));
NS_ENSURE_SUCCESS(rv, rv);
rv = newURI->GetAsciiSpec(aKey);