Bug 1556827 - Dont send referrer in case of meta refresh redirect r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D35810
This commit is contained in:
@@ -5910,13 +5910,6 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal,
|
||||
NS_ENSURE_ARG(aURI);
|
||||
|
||||
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState(aURI);
|
||||
/* We do need to pass in a referrer, but we don't want it to
|
||||
* be sent to the server.
|
||||
* For most refreshes the current URI is an appropriate
|
||||
* internal referrer
|
||||
*/
|
||||
nsCOMPtr<nsIReferrerInfo> referrerInfo =
|
||||
new ReferrerInfo(mCurrentURI, mozilla::net::RP_Unset, false);
|
||||
loadState->SetOriginalURI(mCurrentURI);
|
||||
loadState->SetResultPrincipalURI(aURI);
|
||||
loadState->SetResultPrincipalURIIsSome(true);
|
||||
@@ -5944,6 +5937,8 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal,
|
||||
*/
|
||||
bool equalUri = false;
|
||||
nsresult rv = aURI->Equals(mCurrentURI, &equalUri);
|
||||
|
||||
nsCOMPtr<nsIReferrerInfo> referrerInfo;
|
||||
if (NS_SUCCEEDED(rv) && (!equalUri) && aMetaRefresh &&
|
||||
aDelay <= REFRESH_REDIRECT_TIMER) {
|
||||
/* It is a META refresh based redirection within the threshold time
|
||||
@@ -5952,12 +5947,22 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal,
|
||||
*/
|
||||
loadState->SetLoadType(LOAD_NORMAL_REPLACE);
|
||||
|
||||
/* for redirects we mimic HTTP, which passes the
|
||||
* original referrer
|
||||
/* For redirects we mimic HTTP, which passes the
|
||||
* original referrer.
|
||||
* We will pass in referrer but will not send to server
|
||||
*/
|
||||
referrerInfo = mReferrerInfo;
|
||||
if (mReferrerInfo) {
|
||||
referrerInfo = static_cast<ReferrerInfo*>(mReferrerInfo.get())
|
||||
->CloneWithNewSendReferrer(false);
|
||||
}
|
||||
} else {
|
||||
loadState->SetLoadType(LOAD_REFRESH);
|
||||
/* We do need to pass in a referrer, but we don't want it to
|
||||
* be sent to the server.
|
||||
* For most refreshes the current URI is an appropriate
|
||||
* internal referrer.
|
||||
*/
|
||||
referrerInfo = new ReferrerInfo(mCurrentURI, mozilla::net::RP_Unset, false);
|
||||
}
|
||||
|
||||
loadState->SetReferrerInfo(referrerInfo);
|
||||
|
||||
Reference in New Issue
Block a user