mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Allow a null principal to subsumes others when appropriate (#34617)
Signed-off-by: webbeef <me@webbeef.org>
This commit is contained in:
parent
a85241e635
commit
41030ea9a5
1 changed files with 17 additions and 9 deletions
|
@ -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
|
//TODO is same_origin_domain equivalent to subsumes for our purposes
|
||||||
pub unsafe extern "C" fn subsumes(obj: *mut JSPrincipals, other: *mut JSPrincipals) -> bool {
|
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)) {
|
match (NonNull::new(obj), NonNull::new(other)) {
|
||||||
let obj = ServoJSPrincipalsRef::from_raw_nonnull(obj);
|
(Some(obj), Some(other)) => {
|
||||||
let other = ServoJSPrincipalsRef::from_raw_nonnull(other);
|
let obj = ServoJSPrincipalsRef::from_raw_nonnull(obj);
|
||||||
let obj_origin = obj.origin();
|
let other = ServoJSPrincipalsRef::from_raw_nonnull(other);
|
||||||
let other_origin = other.origin();
|
let obj_origin = obj.origin();
|
||||||
obj_origin.same_origin_domain(&other_origin)
|
let other_origin = other.origin();
|
||||||
} else {
|
obj_origin.same_origin_domain(&other_origin)
|
||||||
warn!("Received null JSPrincipals asrgument.");
|
},
|
||||||
false
|
(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
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue