diff options
author | webbeef <me@webbeef.org> | 2024-12-13 16:33:26 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-14 00:33:26 +0000 |
commit | 41030ea9a50aebfaa2051841fe499a19226b5d09 (patch) | |
tree | 2b83bd35c26fa749c9550be767fe4ee7f7c8ea27 /components | |
parent | a85241e6353a912b312f45de6e9d4668c67761f8 (diff) | |
download | servo-41030ea9a50aebfaa2051841fe499a19226b5d09.tar.gz servo-41030ea9a50aebfaa2051841fe499a19226b5d09.zip |
Allow a null principal to subsumes others when appropriate (#34617)
Signed-off-by: webbeef <me@webbeef.org>
Diffstat (limited to 'components')
-rw-r--r-- | components/script/dom/bindings/principals.rs | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/components/script/dom/bindings/principals.rs b/components/script/dom/bindings/principals.rs index 14a3a826f3a..cf95361bccd 100644 --- a/components/script/dom/bindings/principals.rs +++ b/components/script/dom/bindings/principals.rs @@ -191,14 +191,22 @@ unsafe extern "C" fn principals_is_system_or_addon_principal(_: *mut JSPrincipal //TODO is same_origin_domain equivalent to subsumes for our purposes pub unsafe extern "C" fn subsumes(obj: *mut JSPrincipals, other: *mut JSPrincipals) -> bool { - if let (Some(obj), Some(other)) = (NonNull::new(obj), NonNull::new(other)) { - let obj = ServoJSPrincipalsRef::from_raw_nonnull(obj); - let other = ServoJSPrincipalsRef::from_raw_nonnull(other); - let obj_origin = obj.origin(); - let other_origin = other.origin(); - obj_origin.same_origin_domain(&other_origin) - } else { - warn!("Received null JSPrincipals asrgument."); - false + match (NonNull::new(obj), NonNull::new(other)) { + (Some(obj), Some(other)) => { + let obj = ServoJSPrincipalsRef::from_raw_nonnull(obj); + let other = ServoJSPrincipalsRef::from_raw_nonnull(other); + let obj_origin = obj.origin(); + let other_origin = other.origin(); + obj_origin.same_origin_domain(&other_origin) + }, + (None, Some(_)) => { + // See https://github.com/servo/servo/issues/32999#issuecomment-2542522289 for why + // it's safe to consider the null principal here subsumes all others. + true + }, + _ => { + warn!("Received null JSPrincipal argument."); + false + }, } } |