aboutsummaryrefslogtreecommitdiffstats
path: root/components/shared/net/policy_container.rs
diff options
context:
space:
mode:
authorshanehandley <1322294+shanehandley@users.noreply.github.com>2024-11-19 23:45:10 +1100
committerGitHub <noreply@github.com>2024-11-19 12:45:10 +0000
commit975e2ae85925d5660d09415de33ea77537bcf0d4 (patch)
tree197776b1eafc04477081a131d982435f1340ad43 /components/shared/net/policy_container.rs
parent83f8e888189cc265e73d6a3849f7b8c71c080181 (diff)
downloadservo-975e2ae85925d5660d09415de33ea77537bcf0d4.tar.gz
servo-975e2ae85925d5660d09415de33ea77537bcf0d4.zip
Remove referrer policy from document (#34263)
* Remove the referrer policy from document and rely on its policy container Signed-off-by: Shane Handley <shanehandley@fastmail.com> * Make ReferrerPolicy non-optional, instead using a new enum value to represent the empty string case Signed-off-by: Shane Handley <shanehandley@fastmail.com> * Fix clippy issue Signed-off-by: Shane Handley <shanehandley@fastmail.com> * Fix usage of Option<ReferrerPolicy> in unit test Signed-off-by: Shane Handley <shanehandley@fastmail.com> --------- Signed-off-by: Shane Handley <shanehandley@fastmail.com>
Diffstat (limited to 'components/shared/net/policy_container.rs')
-rw-r--r--components/shared/net/policy_container.rs22
1 files changed, 14 insertions, 8 deletions
diff --git a/components/shared/net/policy_container.rs b/components/shared/net/policy_container.rs
index 7e71033a436..0da85775618 100644
--- a/components/shared/net/policy_container.rs
+++ b/components/shared/net/policy_container.rs
@@ -32,20 +32,26 @@ pub struct PolicyContainer {
/// <https://html.spec.whatwg.org/multipage/#policy-container-csp-list>
pub csp_list: Option<CspList>,
/// <https://html.spec.whatwg.org/multipage/#policy-container-referrer-policy>
- pub referrer_policy: ReferrerPolicy,
+ referrer_policy: ReferrerPolicy,
// https://html.spec.whatwg.org/multipage/#policy-container-embedder-policy
// TODO: Embedder Policy
}
impl PolicyContainer {
- pub fn new(csp_list: Option<CspList>, referrer_policy: Option<ReferrerPolicy>) -> Self {
- PolicyContainer {
- csp_list,
- referrer_policy: referrer_policy.unwrap_or_default(),
- }
- }
-
pub fn set_csp_list(&mut self, csp_list: Option<CspList>) {
self.csp_list = csp_list;
}
+
+ pub fn set_referrer_policy(&mut self, referrer_policy: ReferrerPolicy) {
+ self.referrer_policy = referrer_policy;
+ }
+
+ pub fn get_referrer_policy(&self) -> ReferrerPolicy {
+ // https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-empty-string
+ if self.referrer_policy == ReferrerPolicy::EmptyString {
+ return ReferrerPolicy::default();
+ }
+
+ self.referrer_policy
+ }
}