Issue #2728 - Remove obsolete CSP referrer policy.

This has been superseded by the dedicated Referrer-policy header.
Resolves #2728
This commit is contained in:
Moonchild 2025-04-24 14:27:39 +02:00 committed by roytam1
commit 0331e633bd
16 changed files with 14 additions and 606 deletions

View file

@ -398,48 +398,6 @@ nsCSPContext::GetEnforcesFrameAncestors(bool *outEnforcesFrameAncestors)
return NS_OK;
}
NS_IMETHODIMP
nsCSPContext::GetReferrerPolicy(uint32_t* outPolicy, bool* outIsSet)
{
*outIsSet = false;
*outPolicy = mozilla::net::RP_Default;
nsAutoString refpol;
mozilla::net::ReferrerPolicy previousPolicy = mozilla::net::RP_Default;
for (uint32_t i = 0; i < mPolicies.Length(); i++) {
mPolicies[i]->getReferrerPolicy(refpol);
// only set the referrer policy if not delievered through a CSPRO and
// note that and an empty string in refpol means it wasn't set
// (that's the default in nsCSPPolicy).
if (!mPolicies[i]->getReportOnlyFlag() && !refpol.IsEmpty()) {
// Referrer Directive in CSP is no more used and going to be replaced by
// Referrer-Policy HTTP header. But we still keep using referrer directive,
// and would remove it later.
// Referrer Directive specs is not fully compliant with new referrer policy
// specs. What we are using here:
// - If the value of the referrer directive is invalid, the user agent
// should set the referrer policy to no-referrer.
// - If there are two policies that specify a referrer policy, then they
// must agree or the employed policy is no-referrer.
if (!mozilla::net::IsValidReferrerPolicy(refpol)) {
*outPolicy = mozilla::net::RP_No_Referrer;
*outIsSet = true;
return NS_OK;
}
uint32_t currentPolicy = mozilla::net::ReferrerPolicyFromString(refpol);
if (*outIsSet && previousPolicy != currentPolicy) {
*outPolicy = mozilla::net::RP_No_Referrer;
return NS_OK;
}
*outPolicy = currentPolicy;
*outIsSet = true;
}
}
return NS_OK;
}
NS_IMETHODIMP
nsCSPContext::AppendPolicy(const nsAString& aPolicyString,
bool aReportOnly,