зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1433958 - Change code that sets nsIURI.pathQueryRef to use nsIURIMutator r=mayhemer
MozReview-Commit-ID: HVyZ3E1XuLN --HG-- extra : rebase_source : fd122b3122e0f3eb371d429bd86ad35d09dcfbf6
This commit is contained in:
Родитель
a49f1ae73b
Коммит
7bd0336d01
|
@ -9,6 +9,7 @@
|
|||
#include "mozilla/ipc/URIUtils.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "nsIMessageManager.h"
|
||||
#include "nsIURIMutator.h"
|
||||
#include "nsScriptSecurityManager.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -151,11 +152,10 @@ static already_AddRefed<nsIURI>
|
|||
GetCanonicalClone(nsIURI* aURI)
|
||||
{
|
||||
nsCOMPtr<nsIURI> clone;
|
||||
nsresult rv = aURI->Clone(getter_AddRefs(clone));
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
rv = clone->SetUserPass(EmptyCString());
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
rv = clone->SetPathQueryRef(EmptyCString());
|
||||
nsresult rv = NS_MutateURI(aURI)
|
||||
.SetUserPass(EmptyCString())
|
||||
.SetPathQueryRef(EmptyCString())
|
||||
.Finalize(clone);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
return clone.forget();
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ nsChromeProtocolHandler::NewURI(const nsACString &aSpec,
|
|||
// Chrome: URLs (currently) have no additional structure beyond that provided
|
||||
// by standard URLs, so there is no "outer" given to CreateInstance
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURL> surl;
|
||||
nsCOMPtr<nsIURI> surl;
|
||||
nsCOMPtr<nsIURI> base(aBaseURI);
|
||||
rv = NS_MutateURI(new mozilla::net::nsStandardURL::Mutator())
|
||||
.Apply(NS_MutatorMethod(&nsIStandardURLMutator::Init,
|
||||
|
@ -118,17 +118,13 @@ nsChromeProtocolHandler::NewChannel2(nsIURI* aURI,
|
|||
#ifdef DEBUG
|
||||
// Check that the uri we got is already canonified
|
||||
nsresult debug_rv;
|
||||
nsCOMPtr<nsIURI> debugClone;
|
||||
debug_rv = aURI->Clone(getter_AddRefs(debugClone));
|
||||
nsCOMPtr<nsIURI> debugURL = aURI;
|
||||
debug_rv = nsChromeRegistry::Canonify(debugURL);
|
||||
if (NS_SUCCEEDED(debug_rv)) {
|
||||
nsCOMPtr<nsIURL> debugURL (do_QueryInterface(debugClone));
|
||||
debug_rv = nsChromeRegistry::Canonify(debugURL);
|
||||
bool same;
|
||||
debug_rv = aURI->Equals(debugURL, &same);
|
||||
if (NS_SUCCEEDED(debug_rv)) {
|
||||
bool same;
|
||||
debug_rv = aURI->Equals(debugURL, &same);
|
||||
if (NS_SUCCEEDED(debug_rv)) {
|
||||
NS_ASSERTION(same, "Non-canonified chrome uri passed to nsChromeProtocolHandler::NewChannel!");
|
||||
}
|
||||
NS_ASSERTION(same, "Non-canonified chrome uri passed to nsChromeProtocolHandler::NewChannel!");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "mozilla/StyleSheet.h"
|
||||
#include "mozilla/StyleSheetInlines.h"
|
||||
#include "mozilla/dom/Location.h"
|
||||
#include "nsIURIMutator.h"
|
||||
|
||||
#include "unicode/uloc.h"
|
||||
|
||||
|
@ -152,7 +153,7 @@ nsChromeRegistry::Init()
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsChromeRegistry::GetProviderAndPath(nsIURL* aChromeURL,
|
||||
nsChromeRegistry::GetProviderAndPath(nsIURI* aChromeURL,
|
||||
nsACString& aProvider, nsACString& aPath)
|
||||
{
|
||||
nsresult rv;
|
||||
|
@ -199,7 +200,7 @@ nsChromeRegistry::GetProviderAndPath(nsIURL* aChromeURL,
|
|||
|
||||
|
||||
nsresult
|
||||
nsChromeRegistry::Canonify(nsIURL* aChromeURL)
|
||||
nsChromeRegistry::Canonify(nsCOMPtr<nsIURI>& aChromeURL)
|
||||
{
|
||||
NS_NAMED_LITERAL_CSTRING(kSlash, "/");
|
||||
|
||||
|
@ -228,7 +229,9 @@ nsChromeRegistry::Canonify(nsIURL* aChromeURL)
|
|||
else {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
aChromeURL->SetPathQueryRef(path);
|
||||
return NS_MutateURI(aChromeURL)
|
||||
.SetPathQueryRef(path)
|
||||
.Finalize(aChromeURL);
|
||||
}
|
||||
else {
|
||||
// prevent directory traversals ("..")
|
||||
|
|
|
@ -70,7 +70,10 @@ public:
|
|||
|
||||
static nsChromeRegistry* gChromeRegistry;
|
||||
|
||||
static nsresult Canonify(nsIURL* aChromeURL);
|
||||
// This method can change its parameter, so due to thread safety issues
|
||||
// it should only be called for nsCOMPtr<nsIURI> that is on the stack,
|
||||
// unless you know what you are doing.
|
||||
static nsresult Canonify(nsCOMPtr<nsIURI>& aChromeURL);
|
||||
|
||||
protected:
|
||||
virtual ~nsChromeRegistry();
|
||||
|
@ -91,7 +94,7 @@ protected:
|
|||
uint32_t* aFlags) = 0;
|
||||
|
||||
static nsresult RefreshWindow(nsPIDOMWindowOuter* aWindow);
|
||||
static nsresult GetProviderAndPath(nsIURL* aChromeURL,
|
||||
static nsresult GetProviderAndPath(nsIURI* aChromeURL,
|
||||
nsACString& aProvider, nsACString& aPath);
|
||||
|
||||
bool GetDirectionForLocale(const nsACString& aLocale);
|
||||
|
|
|
@ -101,7 +101,8 @@ NS_INTERFACE_MAP_END
|
|||
nsresult
|
||||
FormData::GetEncodedSubmission(nsIURI* aURI,
|
||||
nsIInputStream** aPostDataStream,
|
||||
int64_t* aPostDataStreamLength)
|
||||
int64_t* aPostDataStreamLength,
|
||||
nsCOMPtr<nsIURI>& aOutURI)
|
||||
{
|
||||
NS_NOTREACHED("Shouldn't call FormData::GetEncodedSubmission");
|
||||
return NS_OK;
|
||||
|
|
|
@ -107,7 +107,7 @@ public:
|
|||
// HTMLFormSubmission
|
||||
virtual nsresult
|
||||
GetEncodedSubmission(nsIURI* aURI, nsIInputStream** aPostDataStream,
|
||||
int64_t* aPostDataStreamLength) override;
|
||||
int64_t* aPostDataStreamLength, nsCOMPtr<nsIURI>& aOutURI) override;
|
||||
|
||||
virtual nsresult AddNameValuePair(const nsAString& aName,
|
||||
const nsAString& aValue) override
|
||||
|
|
|
@ -273,6 +273,7 @@
|
|||
#include "mozilla/MediaManager.h"
|
||||
|
||||
#include "nsIURIClassifier.h"
|
||||
#include "nsIURIMutator.h"
|
||||
#include "mozilla/DocumentStyleRootIterator.h"
|
||||
#include "mozilla/ServoRestyleManager.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
|
@ -9121,8 +9122,8 @@ nsDocument::MaybePreLoadImage(nsIURI* uri, const nsAString &aCrossOriginAttr,
|
|||
void
|
||||
nsDocument::MaybePreconnect(nsIURI* aOrigURI, mozilla::CORSMode aCORSMode)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
if (NS_FAILED(aOrigURI->Clone(getter_AddRefs(uri)))) {
|
||||
NS_MutateURI mutator(aOrigURI);
|
||||
if (NS_FAILED(mutator.GetStatus())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -9134,9 +9135,15 @@ nsDocument::MaybePreconnect(nsIURI* aOrigURI, mozilla::CORSMode aCORSMode)
|
|||
// normalize the path before putting it in the hash to accomplish that.
|
||||
|
||||
if (aCORSMode == CORS_ANONYMOUS) {
|
||||
uri->SetPathQueryRef(NS_LITERAL_CSTRING("/anonymous"));
|
||||
mutator.SetPathQueryRef(NS_LITERAL_CSTRING("/anonymous"));
|
||||
} else {
|
||||
uri->SetPathQueryRef(NS_LITERAL_CSTRING("/"));
|
||||
mutator.SetPathQueryRef(NS_LITERAL_CSTRING("/"));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = mutator.Finalize(uri);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto entry = mPreloadedPreconnects.LookupForAdd(uri);
|
||||
|
|
|
@ -146,6 +146,7 @@
|
|||
#include "nsCSSProps.h"
|
||||
#include "nsIDOMFileList.h"
|
||||
#include "nsIURIFixup.h"
|
||||
#include "nsIURIMutator.h"
|
||||
#ifndef DEBUG
|
||||
#include "nsIAppStartup.h"
|
||||
#include "nsToolkitCompsCID.h"
|
||||
|
@ -5793,8 +5794,11 @@ nsGlobalWindowOuter::PostMessageMozOuter(JSContext* aCx, JS::Handle<JS::Value> a
|
|||
return;
|
||||
}
|
||||
|
||||
if (NS_FAILED(originURI->SetUserPass(EmptyCString())) ||
|
||||
NS_FAILED(originURI->SetPathQueryRef(EmptyCString()))) {
|
||||
nsresult rv = NS_MutateURI(originURI)
|
||||
.SetUserPass(EmptyCString())
|
||||
.SetPathQueryRef(EmptyCString())
|
||||
.Finalize(originURI);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -777,7 +777,8 @@ HTMLFormElement::SubmitSubmission(HTMLFormSubmission* aFormSubmission)
|
|||
int64_t postDataStreamLength = -1;
|
||||
rv = aFormSubmission->GetEncodedSubmission(actionURI,
|
||||
getter_AddRefs(postDataStream),
|
||||
&postDataStreamLength);
|
||||
&postDataStreamLength,
|
||||
actionURI);
|
||||
NS_ENSURE_SUBMIT_SUCCESS(rv);
|
||||
|
||||
rv = linkHandler->OnLinkClickSync(this, actionURI,
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsStringStream.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIURIMutator.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsLinebreakConverter.h"
|
||||
|
@ -113,7 +114,7 @@ public:
|
|||
|
||||
virtual nsresult
|
||||
GetEncodedSubmission(nsIURI* aURI, nsIInputStream** aPostDataStream,
|
||||
int64_t* aPostDataStreamLength) override;
|
||||
int64_t* aPostDataStreamLength, nsCOMPtr<nsIURI>& aOutURI) override;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -268,9 +269,11 @@ HandleMailtoSubject(nsCString& aPath)
|
|||
nsresult
|
||||
FSURLEncoded::GetEncodedSubmission(nsIURI* aURI,
|
||||
nsIInputStream** aPostDataStream,
|
||||
int64_t* aPostDataStreamLength)
|
||||
int64_t* aPostDataStreamLength,
|
||||
nsCOMPtr<nsIURI>& aOutURI)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
aOutURI = aURI;
|
||||
|
||||
*aPostDataStream = nullptr;
|
||||
*aPostDataStreamLength = -1;
|
||||
|
@ -295,8 +298,9 @@ FSURLEncoded::GetEncodedSubmission(nsIURI* aURI,
|
|||
|
||||
path += NS_LITERAL_CSTRING("&force-plain-text=Y&body=") + escapedBody;
|
||||
|
||||
rv = aURI->SetPathQueryRef(path);
|
||||
|
||||
return NS_MutateURI(aURI)
|
||||
.SetPathQueryRef(path)
|
||||
.Finalize(aOutURI);
|
||||
} else {
|
||||
|
||||
nsCOMPtr<nsIInputStream> dataStream;
|
||||
|
@ -331,7 +335,9 @@ FSURLEncoded::GetEncodedSubmission(nsIURI* aURI,
|
|||
|
||||
nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
|
||||
if (url) {
|
||||
url->SetQuery(mQueryString);
|
||||
rv = NS_MutateURI(aURI)
|
||||
.SetQuery(mQueryString)
|
||||
.Finalize(aOutURI);
|
||||
}
|
||||
else {
|
||||
nsAutoCString path;
|
||||
|
@ -356,7 +362,9 @@ FSURLEncoded::GetEncodedSubmission(nsIURI* aURI,
|
|||
// Bug 42616: Add named anchor to end after query string
|
||||
path.Append(mQueryString + namedAnchor);
|
||||
|
||||
aURI->SetPathQueryRef(path);
|
||||
rv = NS_MutateURI(aURI)
|
||||
.SetPathQueryRef(path)
|
||||
.Finalize(aOutURI);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -621,9 +629,11 @@ FSMultipartFormData::AddDataChunk(const nsACString& aName,
|
|||
nsresult
|
||||
FSMultipartFormData::GetEncodedSubmission(nsIURI* aURI,
|
||||
nsIInputStream** aPostDataStream,
|
||||
int64_t* aPostDataStreamLength)
|
||||
int64_t* aPostDataStreamLength,
|
||||
nsCOMPtr<nsIURI>& aOutURI)
|
||||
{
|
||||
nsresult rv;
|
||||
aOutURI = aURI;
|
||||
|
||||
// Make header
|
||||
nsCOMPtr<nsIMIMEInputStream> mimeStream
|
||||
|
@ -686,7 +696,7 @@ public:
|
|||
|
||||
virtual nsresult
|
||||
GetEncodedSubmission(nsIURI* aURI, nsIInputStream** aPostDataStream,
|
||||
int64_t* aPostDataStreaLength) override;
|
||||
int64_t* aPostDataStreaLength, nsCOMPtr<nsIURI>& aOutURI) override;
|
||||
|
||||
private:
|
||||
nsString mBody;
|
||||
|
@ -726,9 +736,11 @@ FSTextPlain::AddNameDirectoryPair(const nsAString& aName,
|
|||
nsresult
|
||||
FSTextPlain::GetEncodedSubmission(nsIURI* aURI,
|
||||
nsIInputStream** aPostDataStream,
|
||||
int64_t* aPostDataStreamLength)
|
||||
int64_t* aPostDataStreamLength,
|
||||
nsCOMPtr<nsIURI>& aOutURI)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
aOutURI = aURI;
|
||||
|
||||
*aPostDataStream = nullptr;
|
||||
*aPostDataStreamLength = -1;
|
||||
|
@ -754,8 +766,9 @@ FSTextPlain::GetEncodedSubmission(nsIURI* aURI,
|
|||
|
||||
path += NS_LITERAL_CSTRING("&force-plain-text=Y&body=") + escapedBody;
|
||||
|
||||
rv = aURI->SetPathQueryRef(path);
|
||||
|
||||
rv = NS_MutateURI(aURI)
|
||||
.SetPathQueryRef(path)
|
||||
.Finalize(aOutURI);
|
||||
} else {
|
||||
// Create data stream.
|
||||
// We do want to send the data through the charset encoder and we want to
|
||||
|
|
|
@ -82,13 +82,15 @@ public:
|
|||
* Given a URI and the current submission, create the final URI and data
|
||||
* stream that will be submitted. Subclasses *must* implement this.
|
||||
*
|
||||
* @param aURI the URI being submitted to [INOUT]
|
||||
* @param aURI the URI being submitted to [IN]
|
||||
* @param aPostDataStream a data stream for POST data [OUT]
|
||||
* @param aPostDataStreamLength a data stream for POST data length [OUT]
|
||||
* @param aOutURI the resulting URI. May be the same as aURI [OUT]
|
||||
*/
|
||||
virtual nsresult
|
||||
GetEncodedSubmission(nsIURI* aURI, nsIInputStream** aPostDataStream,
|
||||
int64_t* aPostDataStreamLength) = 0;
|
||||
int64_t* aPostDataStreamLength,
|
||||
nsCOMPtr<nsIURI>& aOutURI) = 0;
|
||||
|
||||
/**
|
||||
* Get the charset that will be used for submission.
|
||||
|
@ -168,7 +170,7 @@ public:
|
|||
|
||||
virtual nsresult
|
||||
GetEncodedSubmission(nsIURI* aURI, nsIInputStream** aPostDataStream,
|
||||
int64_t* aPostDataStreamLength) override;
|
||||
int64_t* aPostDataStreamLength, nsCOMPtr<nsIURI>& aOutURI) override;
|
||||
|
||||
void GetContentType(nsACString& aContentType)
|
||||
{
|
||||
|
|
|
@ -625,7 +625,7 @@ nsWebBrowserPersist::SerializeNextFile()
|
|||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
break;
|
||||
}
|
||||
rv = AppendPathToURI(fileAsURI, data->mFilename);
|
||||
rv = AppendPathToURI(fileAsURI, data->mFilename, fileAsURI);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
break;
|
||||
}
|
||||
|
@ -1305,7 +1305,7 @@ nsWebBrowserPersist::GetLocalFileFromURI(nsIURI *aURI, nsIFile **aLocalFile)
|
|||
}
|
||||
|
||||
/* static */ nsresult
|
||||
nsWebBrowserPersist::AppendPathToURI(nsIURI *aURI, const nsAString & aPath)
|
||||
nsWebBrowserPersist::AppendPathToURI(nsIURI *aURI, const nsAString & aPath, nsCOMPtr<nsIURI>& aOutURI)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aURI);
|
||||
|
||||
|
@ -1322,9 +1322,10 @@ nsWebBrowserPersist::AppendPathToURI(nsIURI *aURI, const nsAString & aPath)
|
|||
|
||||
// Store the path back on the URI
|
||||
AppendUTF16toUTF8(aPath, newPath);
|
||||
aURI->SetPathQueryRef(newPath);
|
||||
|
||||
return NS_OK;
|
||||
return NS_MutateURI(aURI)
|
||||
.SetPathQueryRef(newPath)
|
||||
.Finalize(aOutURI);
|
||||
}
|
||||
|
||||
nsresult nsWebBrowserPersist::SaveURIInternal(
|
||||
|
@ -2576,7 +2577,7 @@ nsWebBrowserPersist::URIData::GetLocalURI(nsIURI *targetBaseURI, nsCString& aSpe
|
|||
} else {
|
||||
rv = mDataPath->Clone(getter_AddRefs(fileAsURI));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = AppendPathToURI(fileAsURI, mFilename);
|
||||
rv = AppendPathToURI(fileAsURI, mFilename, fileAsURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
@ -2699,7 +2700,7 @@ nsWebBrowserPersist::SaveSubframeContent(
|
|||
nsCOMPtr<nsIURI> frameURI;
|
||||
rv = mCurrentDataPath->Clone(getter_AddRefs(frameURI));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = AppendPathToURI(frameURI, filenameWithExt);
|
||||
rv = AppendPathToURI(frameURI, filenameWithExt, frameURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Work out the path for the subframe data
|
||||
|
@ -2710,7 +2711,7 @@ nsWebBrowserPersist::SaveSubframeContent(
|
|||
|
||||
// Append _data
|
||||
newFrameDataPath.AppendLiteral("_data");
|
||||
rv = AppendPathToURI(frameDataURI, newFrameDataPath);
|
||||
rv = AppendPathToURI(frameDataURI, newFrameDataPath, frameDataURI);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Make frame document & data path conformant and unique
|
||||
|
|
|
@ -91,7 +91,7 @@ private:
|
|||
void CleanupLocalFiles();
|
||||
nsresult GetValidURIFromObject(nsISupports *aObject, nsIURI **aURI) const;
|
||||
static nsresult GetLocalFileFromURI(nsIURI *aURI, nsIFile **aLocalFile);
|
||||
static nsresult AppendPathToURI(nsIURI *aURI, const nsAString & aPath);
|
||||
static nsresult AppendPathToURI(nsIURI *aURI, const nsAString & aPath, nsCOMPtr<nsIURI>& aOutURI);
|
||||
nsresult MakeAndStoreLocalFilenameInURIMap(
|
||||
nsIURI *aURI, bool aNeedsPersisting, URIData **aData);
|
||||
nsresult MakeOutputStream(
|
||||
|
|
|
@ -47,6 +47,11 @@ public:
|
|||
SetURI(uri);
|
||||
}
|
||||
|
||||
void UpdateURI(nsIURI *aURI) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(NS_IsMainThread(), "Not thread-safe.");
|
||||
mURI = aURI;
|
||||
}
|
||||
|
||||
nsIProxyInfo *ProxyInfo() {
|
||||
return mProxyInfo;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "nsIRunnable.h"
|
||||
#include "nsISocketTransportService.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIURIMutator.h"
|
||||
#include "nsILoadInfo.h"
|
||||
#include "NullPrincipal.h"
|
||||
#include "nsIAuthPrompt2.h"
|
||||
|
@ -1645,11 +1646,19 @@ nsFtpState::Init(nsFtpChannel *channel)
|
|||
|
||||
removeParamsFromPath(path);
|
||||
|
||||
nsCOMPtr<nsIURI> outURI;
|
||||
// FTP parameters such as type=i are ignored
|
||||
if (url) {
|
||||
url->SetFilePath(path);
|
||||
rv = NS_MutateURI(url)
|
||||
.SetFilePath(path)
|
||||
.Finalize(outURI);
|
||||
} else {
|
||||
mChannel->URI()->SetPathQueryRef(path);
|
||||
rv = NS_MutateURI(mChannel->URI())
|
||||
.SetPathQueryRef(path)
|
||||
.Finalize(outURI);
|
||||
}
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mChannel->UpdateURI(outURI);
|
||||
}
|
||||
|
||||
// Skip leading slash
|
||||
|
|
|
@ -1793,7 +1793,9 @@ HttpBaseChannel::SetReferrerWithPolicy(nsIURI *referrer,
|
|||
|
||||
// strip away any userpass; we don't want to be giving out passwords ;-)
|
||||
// This is required by Referrer Policy stripping algorithm.
|
||||
rv = clone->SetUserPass(EmptyCString());
|
||||
rv = NS_MutateURI(clone)
|
||||
.SetUserPass(EmptyCString())
|
||||
.Finalize(clone);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// 0: full URI
|
||||
|
@ -1871,9 +1873,10 @@ HttpBaseChannel::SetReferrerWithPolicy(nsIURI *referrer,
|
|||
rv = url->GetFilePath(path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
spec.Append(path);
|
||||
rv = url->SetQuery(EmptyCString());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = url->SetRef(EmptyCString());
|
||||
rv = NS_MutateURI(url)
|
||||
.SetQuery(EmptyCString())
|
||||
.SetRef(EmptyCString())
|
||||
.Finalize(clone);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
break;
|
||||
}
|
||||
|
@ -1885,7 +1888,9 @@ HttpBaseChannel::SetReferrerWithPolicy(nsIURI *referrer,
|
|||
case 2: // scheme+host+port+/
|
||||
spec.AppendLiteral("/");
|
||||
// This nukes any query/ref present as well in the case of nsStandardURL
|
||||
rv = clone->SetPathQueryRef(EmptyCString());
|
||||
rv = NS_MutateURI(clone)
|
||||
.SetPathQueryRef(EmptyCString())
|
||||
.Finalize(clone);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "nsStringStream.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsIURIMutator.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsIDirIndex.h"
|
||||
#include "nsURLHelper.h"
|
||||
|
@ -25,6 +26,7 @@
|
|||
#include "nsString.h"
|
||||
#include <algorithm>
|
||||
#include "nsIChannel.h"
|
||||
#include "mozilla/Unused.h"
|
||||
|
||||
using mozilla::intl::LocaleService;
|
||||
|
||||
|
@ -249,7 +251,9 @@ nsIndexedToHTML::DoOnStartRequest(nsIRequest* request, nsISupports *aContext,
|
|||
if (baseUri.Last() != '/') {
|
||||
baseUri.Append('/');
|
||||
path.Append('/');
|
||||
uri->SetPathQueryRef(path);
|
||||
mozilla::Unused << NS_MutateURI(uri)
|
||||
.SetPathQueryRef(path)
|
||||
.Finalize(uri);
|
||||
}
|
||||
if (!path.EqualsLiteral("/")) {
|
||||
rv = uri->Resolve(NS_LITERAL_CSTRING(".."), parentStr);
|
||||
|
|
|
@ -502,16 +502,16 @@ function do_test_mutate_ref(aTest, aSuffix) {
|
|||
var pathWithSuffix = aTest.pathQueryRef + aSuffix;
|
||||
do_info("testing that setting path to " +
|
||||
pathWithSuffix + " and then clearing ref does what we expect");
|
||||
testURI.pathQueryRef = pathWithSuffix;
|
||||
testURI = testURI.mutate().setPathQueryRef(pathWithSuffix).finalize();
|
||||
testURI.ref = "";
|
||||
do_check_uri_eq(testURI, refURIWithoutSuffix);
|
||||
do_check_uri_eqExceptRef(testURI, refURIWithSuffix);
|
||||
|
||||
// Also: make sure that clearing .pathQueryRef also clears .ref
|
||||
testURI.pathQueryRef = pathWithSuffix;
|
||||
testURI = testURI.mutate().setPathQueryRef(pathWithSuffix).finalize();
|
||||
do_info("testing that clearing path from " +
|
||||
pathWithSuffix + " also clears .ref");
|
||||
testURI.pathQueryRef = "";
|
||||
testURI = testURI.mutate().setPathQueryRef("").finalize();
|
||||
Assert.equal(testURI.ref, "");
|
||||
}
|
||||
}
|
||||
|
@ -525,7 +525,7 @@ function do_test_immutable(aTest) {
|
|||
var URI = NetUtil.newURI(aTest.spec);
|
||||
// All the non-readonly attributes on nsIURI.idl:
|
||||
var propertiesToCheck = ["spec", "scheme", "userPass", "username", "password",
|
||||
"host", "port", "pathQueryRef", "query", "ref"];
|
||||
"host", "port", "query", "ref"];
|
||||
|
||||
propertiesToCheck.forEach(function(aProperty) {
|
||||
var threw = false;
|
||||
|
|
|
@ -603,16 +603,16 @@ function do_test_mutate_ref(aTest, aSuffix) {
|
|||
var pathWithSuffix = aTest.pathQueryRef + aSuffix;
|
||||
do_info("testing that setting path to " +
|
||||
pathWithSuffix + " and then clearing ref does what we expect");
|
||||
testURI.pathQueryRef = pathWithSuffix;
|
||||
testURI = testURI.mutate().setPathQueryRef(pathWithSuffix).finalize();
|
||||
testURI.ref = "";
|
||||
do_check_uri_eq(testURI, refURIWithoutSuffix);
|
||||
do_check_uri_eqExceptRef(testURI, refURIWithSuffix);
|
||||
|
||||
// Also: make sure that clearing .pathQueryRef also clears .ref
|
||||
testURI.pathQueryRef = pathWithSuffix;
|
||||
testURI = testURI.mutate().setPathQueryRef(pathWithSuffix).finalize();
|
||||
do_info("testing that clearing path from " +
|
||||
pathWithSuffix + " also clears .ref");
|
||||
testURI.pathQueryRef = "";
|
||||
testURI = testURI.mutate().setPathQueryRef("").finalize();
|
||||
Assert.equal(testURI.ref, "");
|
||||
}
|
||||
}
|
||||
|
@ -626,7 +626,7 @@ function do_test_immutable(aTest) {
|
|||
var URI = NetUtil.newURI(aTest.spec);
|
||||
// All the non-readonly attributes on nsIURI.idl:
|
||||
var propertiesToCheck = ["scheme", "userPass", "username", "password",
|
||||
"host", "port", "pathQueryRef", "query", "ref"];
|
||||
"host", "port", "query", "ref"];
|
||||
|
||||
propertiesToCheck.forEach(function(aProperty) {
|
||||
var threw = false;
|
||||
|
|
|
@ -55,8 +55,8 @@ add_test(function test_setEmptyPath()
|
|||
{
|
||||
symmetricEquality(false, target, provided);
|
||||
|
||||
provided.pathQueryRef = "";
|
||||
target.pathQueryRef = "";
|
||||
provided = provided.mutate().setPathQueryRef("").finalize();
|
||||
target = target.mutate().setPathQueryRef("").finalize();
|
||||
|
||||
Assert.equal(provided.spec, target.spec);
|
||||
symmetricEquality(true, target, provided);
|
||||
|
@ -302,7 +302,7 @@ add_test(function test_hugeStringThrows()
|
|||
|
||||
let hugeString = new Array(maxLen + 1).fill("a").join("");
|
||||
let properties = ["scheme", "userPass", "username",
|
||||
"password", "host", "pathQueryRef", "ref",
|
||||
"password", "host", "ref",
|
||||
"query", "filePath"];
|
||||
for (let prop of properties) {
|
||||
Assert.throws(() => url[prop] = hugeString,
|
||||
|
@ -313,6 +313,7 @@ add_test(function test_hugeStringThrows()
|
|||
let setters = [
|
||||
{ method: "setSpec", qi: Ci.nsIURIMutator },
|
||||
{ method: "setHostPort", qi: Ci.nsIURIMutator },
|
||||
{ method: "setPathQueryRef", qi: Ci.nsIURIMutator },
|
||||
{ method: "setFileName", qi: Ci.nsIURLMutator },
|
||||
{ method: "setFileExtension", qi: Ci.nsIURLMutator },
|
||||
{ method: "setFileBaseName", qi: Ci.nsIURLMutator },
|
||||
|
|
|
@ -314,8 +314,9 @@ function run_test_provider() {
|
|||
|
||||
check_mapping(provider.uri, provider.id);
|
||||
|
||||
let u2 = provider.uri.clone();
|
||||
u2.pathQueryRef = "notmapped";
|
||||
let u2 = provider.uri.mutate()
|
||||
.setPathQueryRef("notmapped")
|
||||
.finalize();
|
||||
Assert.equal(AddonManager.mapURIToAddonID(u2), null);
|
||||
|
||||
AddonManagerPrivate.unregisterProvider(provider);
|
||||
|
|
Загрузка…
Ссылка в новой задаче