зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1406253 - Part 1: Rename imgIRequest.currentURI to finalURI to prevent confusion. r=bz
The "current URL" in the spec: https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-currentsrc maps to imgIRequest.URI, not currentURI. Rename imgIRequest.currentURI to finalURI to prevent such confusion. MozReview-Commit-ID: CjBh2V4z8K9 --HG-- extra : rebase_source : 01277d16ef12845e12cc846f9dd4a21ceeca283b
This commit is contained in:
Родитель
4aa48e5d9c
Коммит
326d642792
|
@ -618,7 +618,7 @@ static nsresult AppendImagePromise(nsITransferable* aTransferable,
|
|||
NS_ENSURE_TRUE(mimeService, NS_OK);
|
||||
|
||||
nsCOMPtr<nsIURI> imgUri;
|
||||
rv = aImgRequest->GetCurrentURI(getter_AddRefs(imgUri));
|
||||
rv = aImgRequest->GetFinalURI(getter_AddRefs(imgUri));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIURL> imgUrl = do_QueryInterface(imgUri);
|
||||
|
|
|
@ -88,7 +88,7 @@ interface imgIRequest : nsIRequest
|
|||
/**
|
||||
* The URI of the resource we ended up loading after all redirects, etc.
|
||||
*/
|
||||
readonly attribute nsIURI currentURI;
|
||||
readonly attribute nsIURI finalURI;
|
||||
|
||||
readonly attribute imgINotificationObserver notificationObserver;
|
||||
|
||||
|
|
|
@ -620,14 +620,14 @@ ShouldLoadCachedImage(imgRequest* aImgRequest,
|
|||
* Cached images are keyed off of the first uri in a redirect chain.
|
||||
* Hence content policies don't get a chance to test the intermediate hops
|
||||
* or the final desitnation. Here we test the final destination using
|
||||
* mCurrentURI off of the imgRequest and passing it into content policies.
|
||||
* mFinalURI off of the imgRequest and passing it into content policies.
|
||||
* For Mixed Content Blocker, we do an additional check to determine if any
|
||||
* of the intermediary hops went through an insecure redirect with the
|
||||
* mHadInsecureRedirect flag
|
||||
*/
|
||||
bool insecureRedirect = aImgRequest->HadInsecureRedirect();
|
||||
nsCOMPtr<nsIURI> contentLocation;
|
||||
aImgRequest->GetCurrentURI(getter_AddRefs(contentLocation));
|
||||
aImgRequest->GetFinalURI(getter_AddRefs(contentLocation));
|
||||
nsresult rv;
|
||||
|
||||
int16_t decision = nsIContentPolicy::REJECT_REQUEST;
|
||||
|
@ -2985,12 +2985,12 @@ imgCacheValidator::OnStartRequest(nsIRequest* aRequest, nsISupports* ctxt)
|
|||
nsCOMPtr<nsIURI> channelURI;
|
||||
channel->GetURI(getter_AddRefs(channelURI));
|
||||
|
||||
nsCOMPtr<nsIURI> currentURI;
|
||||
mRequest->GetCurrentURI(getter_AddRefs(currentURI));
|
||||
nsCOMPtr<nsIURI> finalURI;
|
||||
mRequest->GetFinalURI(getter_AddRefs(finalURI));
|
||||
|
||||
bool sameURI = false;
|
||||
if (channelURI && currentURI) {
|
||||
channelURI->Equals(currentURI, &sameURI);
|
||||
if (channelURI && finalURI) {
|
||||
channelURI->Equals(finalURI, &sameURI);
|
||||
}
|
||||
|
||||
if (isFromCache && sameURI) {
|
||||
|
|
|
@ -89,7 +89,7 @@ imgRequest::~imgRequest()
|
|||
|
||||
nsresult
|
||||
imgRequest::Init(nsIURI *aURI,
|
||||
nsIURI *aCurrentURI,
|
||||
nsIURI *aFinalURI,
|
||||
bool aHadInsecureRedirect,
|
||||
nsIRequest *aRequest,
|
||||
nsIChannel *aChannel,
|
||||
|
@ -105,7 +105,7 @@ imgRequest::Init(nsIURI *aURI,
|
|||
|
||||
MOZ_ASSERT(!mImage, "Multiple calls to init");
|
||||
MOZ_ASSERT(aURI, "No uri");
|
||||
MOZ_ASSERT(aCurrentURI, "No current uri");
|
||||
MOZ_ASSERT(aFinalURI, "No final uri");
|
||||
MOZ_ASSERT(aRequest, "No request");
|
||||
MOZ_ASSERT(aChannel, "No channel");
|
||||
|
||||
|
@ -116,7 +116,7 @@ imgRequest::Init(nsIURI *aURI,
|
|||
mURI = new ImageURL(aURI, rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mCurrentURI = aCurrentURI;
|
||||
mFinalURI = aFinalURI;
|
||||
mRequest = aRequest;
|
||||
mChannel = aChannel;
|
||||
mTimedChannel = do_QueryInterface(mChannel);
|
||||
|
@ -125,11 +125,11 @@ imgRequest::Init(nsIURI *aURI,
|
|||
mCORSMode = aCORSMode;
|
||||
mReferrerPolicy = aReferrerPolicy;
|
||||
|
||||
// If the original URI and the current URI are different, check whether the
|
||||
// original URI is secure. We deliberately don't take the current URI into
|
||||
// If the original URI and the final URI are different, check whether the
|
||||
// original URI is secure. We deliberately don't take the final URI into
|
||||
// account, as it needs to be handled using more complicated rules than
|
||||
// earlier elements of the redirect chain.
|
||||
if (aURI != aCurrentURI) {
|
||||
if (aURI != aFinalURI) {
|
||||
bool isHttps = false;
|
||||
bool isChrome = false;
|
||||
bool schemeLocal = false;
|
||||
|
@ -437,14 +437,14 @@ nsresult imgRequest::GetURI(ImageURL** aURI)
|
|||
}
|
||||
|
||||
nsresult
|
||||
imgRequest::GetCurrentURI(nsIURI** aURI)
|
||||
imgRequest::GetFinalURI(nsIURI** aURI)
|
||||
{
|
||||
MOZ_ASSERT(aURI);
|
||||
|
||||
LOG_FUNC(gImgLog, "imgRequest::GetCurrentURI");
|
||||
LOG_FUNC(gImgLog, "imgRequest::GetFinalURI");
|
||||
|
||||
if (mCurrentURI) {
|
||||
*aURI = mCurrentURI;
|
||||
if (mFinalURI) {
|
||||
*aURI = mFinalURI;
|
||||
NS_ADDREF(*aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1322,8 +1322,8 @@ imgRequest::OnRedirectVerifyCallback(nsresult result)
|
|||
if (LOG_TEST(LogLevel::Debug)) {
|
||||
LOG_MSG_WITH_PARAM(gImgLog,
|
||||
"imgRequest::OnChannelRedirect", "old",
|
||||
mCurrentURI ? mCurrentURI->GetSpecOrDefault().get()
|
||||
: "");
|
||||
mFinalURI ? mFinalURI->GetSpecOrDefault().get()
|
||||
: "");
|
||||
}
|
||||
|
||||
// If the previous URI is a non-HTTPS URI, record that fact for later use by
|
||||
|
@ -1332,9 +1332,9 @@ imgRequest::OnRedirectVerifyCallback(nsresult result)
|
|||
bool isHttps = false;
|
||||
bool isChrome = false;
|
||||
bool schemeLocal = false;
|
||||
if (NS_FAILED(mCurrentURI->SchemeIs("https", &isHttps)) ||
|
||||
NS_FAILED(mCurrentURI->SchemeIs("chrome", &isChrome)) ||
|
||||
NS_FAILED(NS_URIChainHasFlags(mCurrentURI,
|
||||
if (NS_FAILED(mFinalURI->SchemeIs("https", &isHttps)) ||
|
||||
NS_FAILED(mFinalURI->SchemeIs("chrome", &isChrome)) ||
|
||||
NS_FAILED(NS_URIChainHasFlags(mFinalURI,
|
||||
nsIProtocolHandler::URI_IS_LOCAL_RESOURCE,
|
||||
&schemeLocal)) ||
|
||||
(!isHttps && !isChrome && !schemeLocal)) {
|
||||
|
@ -1352,20 +1352,20 @@ imgRequest::OnRedirectVerifyCallback(nsresult result)
|
|||
}
|
||||
}
|
||||
|
||||
// Update the current URI.
|
||||
mChannel->GetURI(getter_AddRefs(mCurrentURI));
|
||||
// Update the final URI.
|
||||
mChannel->GetURI(getter_AddRefs(mFinalURI));
|
||||
|
||||
if (LOG_TEST(LogLevel::Debug)) {
|
||||
LOG_MSG_WITH_PARAM(gImgLog, "imgRequest::OnChannelRedirect", "new",
|
||||
mCurrentURI ? mCurrentURI->GetSpecOrDefault().get()
|
||||
: "");
|
||||
mFinalURI ? mFinalURI->GetSpecOrDefault().get()
|
||||
: "");
|
||||
}
|
||||
|
||||
// Make sure we have a protocol that returns data rather than opens an
|
||||
// external application, e.g. 'mailto:'.
|
||||
bool doesNotReturnData = false;
|
||||
nsresult rv =
|
||||
NS_URIChainHasFlags(mCurrentURI,
|
||||
NS_URIChainHasFlags(mFinalURI,
|
||||
nsIProtocolHandler::URI_DOES_NOT_RETURN_DATA,
|
||||
&doesNotReturnData);
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
|
||||
|
||||
MOZ_MUST_USE nsresult Init(nsIURI* aURI,
|
||||
nsIURI* aCurrentURI,
|
||||
nsIURI* aFinalURI,
|
||||
bool aHadInsecureRedirect,
|
||||
nsIRequest* aRequest,
|
||||
nsIChannel* aChannel,
|
||||
|
@ -116,7 +116,7 @@ public:
|
|||
bool GetMultipart() const;
|
||||
|
||||
// Returns whether we went through an insecure (non-HTTPS) redirect at some
|
||||
// point during loading. This does not consider the current URI.
|
||||
// point during loading. This does not consider the final URI.
|
||||
bool HadInsecureRedirect() const;
|
||||
|
||||
// The CORS mode for which we loaded this image.
|
||||
|
@ -152,7 +152,7 @@ public:
|
|||
|
||||
// OK to use on any thread.
|
||||
nsresult GetURI(ImageURL** aURI);
|
||||
nsresult GetCurrentURI(nsIURI** aURI);
|
||||
nsresult GetFinalURI(nsIURI** aURI);
|
||||
bool IsScheme(const char* aScheme) const;
|
||||
bool IsChrome() const;
|
||||
bool IsData() const;
|
||||
|
@ -237,7 +237,7 @@ private:
|
|||
// refcounting issues with nsStandardURL.
|
||||
RefPtr<ImageURL> mURI;
|
||||
// The URI of the resource we ended up loading after all redirects, etc.
|
||||
nsCOMPtr<nsIURI> mCurrentURI;
|
||||
nsCOMPtr<nsIURI> mFinalURI;
|
||||
// The principal which triggered the load of this image. Generally either
|
||||
// the principal of the document the image is being loaded into, or of the
|
||||
// stylesheet which specified the image to load. Used when validating for CORS.
|
||||
|
|
|
@ -745,13 +745,13 @@ imgRequestProxy::GetURI(nsIURI** aURI)
|
|||
}
|
||||
|
||||
nsresult
|
||||
imgRequestProxy::GetCurrentURI(nsIURI** aURI)
|
||||
imgRequestProxy::GetFinalURI(nsIURI** aURI)
|
||||
{
|
||||
if (!GetOwner()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return GetOwner()->GetCurrentURI(aURI);
|
||||
return GetOwner()->GetFinalURI(aURI);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
Загрузка…
Ссылка в новой задаче