From 547071d298c8d6b1d07e2e5116bab0ad01668013 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Mon, 5 May 2025 13:07:18 +0800 Subject: [PATCH 1/4] Update meta referrer parsing Signed-off-by: Keith Yeung --- components/script/dom/htmlmetaelement.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index e94a5e1ff33..31e53aad377 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.rs @@ -5,7 +5,7 @@ use dom_struct::dom_struct; use html5ever::{LocalName, Prefix, local_name, ns}; use js::rust::HandleObject; -use style::str::HTML_SPACE_CHARACTERS; +use style::{attr::AttrValue, str::HTML_SPACE_CHARACTERS}; use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::HTMLMetaElementBinding::HTMLMetaElementMethods; @@ -108,7 +108,15 @@ impl HTMLMetaElement { .get_attribute(&ns!(), &local_name!("content")); if let Some(attr) = content { let attr = attr.value(); - let attr_val = attr.trim(); + let attr_val = match &*attr { + AttrValue::TokenList(_, list) => { + let Some(last_atom) = list.last() else { + return; + }; + last_atom.trim() + }, + a => a.trim(), + }; if !attr_val.is_empty() { doc.set_referrer_policy(determine_policy_for_token(attr_val)); } From a3297c5f4ffe826362035dda1e58c16fca9445d0 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Mon, 5 May 2025 16:40:02 +0800 Subject: [PATCH 2/4] Fix formatting Signed-off-by: Keith Yeung --- components/script/dom/htmlmetaelement.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index 31e53aad377..5a133ed0cf4 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.rs @@ -5,7 +5,8 @@ use dom_struct::dom_struct; use html5ever::{LocalName, Prefix, local_name, ns}; use js::rust::HandleObject; -use style::{attr::AttrValue, str::HTML_SPACE_CHARACTERS}; +use style::attr::AttrValue; +use style::str::HTML_SPACE_CHARACTERS; use crate::dom::attr::Attr; use crate::dom::bindings::codegen::Bindings::HTMLMetaElementBinding::HTMLMetaElementMethods; From a1d00237a96a807f44a849c2a6a7c17eb6fe57a8 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Mon, 5 May 2025 17:45:07 +0800 Subject: [PATCH 3/4] Rename variable Signed-off-by: Keith Yeung --- components/script/dom/htmlmetaelement.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index 5a133ed0cf4..639a1cf2643 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.rs @@ -116,7 +116,7 @@ impl HTMLMetaElement { }; last_atom.trim() }, - a => a.trim(), + val => val.trim(), }; if !attr_val.is_empty() { doc.set_referrer_policy(determine_policy_for_token(attr_val)); From b144cf8b10e1174c49208e33eb78b97302a33f8b Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Mon, 5 May 2025 18:02:19 +0800 Subject: [PATCH 4/4] Add origin-when-crossorigin legacy value Signed-off-by: Keith Yeung --- components/script/dom/document.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 9ce24038259..27255a04fe7 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -6666,7 +6666,7 @@ pub(crate) fn determine_policy_for_token(token: &str) -> ReferrerPolicy { "same-origin" => ReferrerPolicy::SameOrigin, "strict-origin" => ReferrerPolicy::StrictOrigin, "default" | "strict-origin-when-cross-origin" => ReferrerPolicy::StrictOriginWhenCrossOrigin, - "origin-when-cross-origin" => ReferrerPolicy::OriginWhenCrossOrigin, + "origin-when-cross-origin" | "origin-when-crossorigin" => ReferrerPolicy::OriginWhenCrossOrigin, "always" | "unsafe-url" => ReferrerPolicy::UnsafeUrl, _ => ReferrerPolicy::EmptyString, }