зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1556489 - P21 - Cache the original referrer before url classification has been applied to send back to the content process, since the docshell expects to find the original. r=mayhemer,tnguyen
Differential Revision: https://phabricator.services.mozilla.com/D42258
This commit is contained in:
Родитель
9cdcb33634
Коммит
4151ea2a94
|
@ -1569,10 +1569,16 @@ HttpBaseChannel::GetReferrerInfo(nsIReferrerInfo** aReferrerInfo) {
|
|||
}
|
||||
|
||||
nsresult HttpBaseChannel::SetReferrerInfo(nsIReferrerInfo* aReferrerInfo,
|
||||
bool aClone, bool aCompute) {
|
||||
bool aClone, bool aCompute,
|
||||
bool aSetOriginal) {
|
||||
LOG(("HttpBaseChannel::SetReferrerInfo [this=%p aClone(%d) aCompute(%d)]\n",
|
||||
this, aClone, aCompute));
|
||||
ENSURE_CALLED_BEFORE_CONNECT();
|
||||
|
||||
mReferrerInfo = aReferrerInfo;
|
||||
if (aSetOriginal) {
|
||||
mOriginalReferrerInfo = aReferrerInfo;
|
||||
}
|
||||
|
||||
// clear existing referrer, if any
|
||||
nsresult rv = ClearReferrerHeader();
|
||||
|
@ -1586,6 +1592,9 @@ nsresult HttpBaseChannel::SetReferrerInfo(nsIReferrerInfo* aReferrerInfo,
|
|||
|
||||
if (aClone) {
|
||||
mReferrerInfo = static_cast<dom::ReferrerInfo*>(aReferrerInfo)->Clone();
|
||||
if (aSetOriginal) {
|
||||
mOriginalReferrerInfo = mReferrerInfo;
|
||||
}
|
||||
}
|
||||
|
||||
dom::ReferrerInfo* referrerInfo =
|
||||
|
@ -3143,7 +3152,7 @@ HttpBaseChannel::CloneReplacementChannelConfig(bool aPreserveMethod,
|
|||
config.privateBrowsing = Some(mPrivateBrowsing);
|
||||
}
|
||||
|
||||
if (mReferrerInfo) {
|
||||
if (mOriginalReferrerInfo) {
|
||||
dom::ReferrerPolicy referrerPolicy = dom::ReferrerPolicy::_empty;
|
||||
nsAutoCString tRPHeaderCValue;
|
||||
Unused << GetResponseHeader(NS_LITERAL_CSTRING("referrer-policy"),
|
||||
|
@ -3160,11 +3169,11 @@ HttpBaseChannel::CloneReplacementChannelConfig(bool aPreserveMethod,
|
|||
// changes, we must not use the old computed value, and have to compute
|
||||
// again.
|
||||
nsCOMPtr<nsIReferrerInfo> referrerInfo =
|
||||
dom::ReferrerInfo::CreateFromOtherAndPolicyOverride(mReferrerInfo,
|
||||
referrerPolicy);
|
||||
dom::ReferrerInfo::CreateFromOtherAndPolicyOverride(
|
||||
mOriginalReferrerInfo, referrerPolicy);
|
||||
config.referrerInfo = referrerInfo;
|
||||
} else {
|
||||
config.referrerInfo = mReferrerInfo;
|
||||
config.referrerInfo = mOriginalReferrerInfo;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -472,8 +472,11 @@ class HttpBaseChannel : public nsHashPropertyBag,
|
|||
}
|
||||
|
||||
// Set referrerInfo and compute the referrer header if neccessary.
|
||||
// Pass true for aSetOriginal if this is a new referrer and should
|
||||
// overwrite the 'original' value, false if this is a mutation (like
|
||||
// stripping the path).
|
||||
nsresult SetReferrerInfo(nsIReferrerInfo* aReferrerInfo, bool aClone,
|
||||
bool aCompute);
|
||||
bool aCompute, bool aSetOriginal = true);
|
||||
|
||||
struct ReplacementChannelConfig {
|
||||
ReplacementChannelConfig() = default;
|
||||
|
@ -599,6 +602,10 @@ class HttpBaseChannel : public nsHashPropertyBag,
|
|||
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
||||
nsCOMPtr<nsIProgressEventSink> mProgressSink;
|
||||
nsCOMPtr<nsIReferrerInfo> mReferrerInfo;
|
||||
// We cache the original value of mReferrerInfo, since
|
||||
// we trim the referrer to not expose the full path to remote
|
||||
// usage.
|
||||
nsCOMPtr<nsIReferrerInfo> mOriginalReferrerInfo;
|
||||
nsCOMPtr<nsIApplicationCache> mApplicationCache;
|
||||
nsCOMPtr<nsIURI> mAPIRedirectToURI;
|
||||
nsCOMPtr<nsIURI> mProxyURI;
|
||||
|
|
|
@ -10374,7 +10374,9 @@ void nsHttpChannel::ReEvaluateReferrerAfterTrackingStatusIsKnown() {
|
|||
isPrivate)) {
|
||||
nsCOMPtr<nsIReferrerInfo> newReferrerInfo =
|
||||
referrerInfo->CloneWithNewPolicy(ReferrerPolicy::_empty);
|
||||
SetReferrerInfo(newReferrerInfo, false, true);
|
||||
// Pass false for the 3rd bool to not overwrite the original
|
||||
// referrer for these referrer policy mutations.
|
||||
SetReferrerInfo(newReferrerInfo, false, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче