mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Move CSP code into one entrypoint (#37604)
This refactoring moves various CSP-related methods away from GlobalScope and Document into a dedicated entrypoint. It also reduces the amount of imports of the CSP crate, so that types are consolidated into this one entrypoint. That way, we control how CSP code interacts with the script crate. For reviewing purposes, I split up the refactoring into separate distinct commits that all move 1 method(group) into the new file. Testing: no change in behavior, only a build improvement + code cleanup --------- Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com> Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
This commit is contained in:
parent
2265570c88
commit
fc20d8b2e1
29 changed files with 424 additions and 289 deletions
|
@ -12,7 +12,6 @@ use std::rc::Rc;
|
|||
use std::str::FromStr;
|
||||
use std::{fmt, mem};
|
||||
|
||||
use content_security_policy as csp;
|
||||
use cssparser::{Parser as CssParser, ParserInput as CssParserInput, match_ignore_ascii_case};
|
||||
use devtools_traits::AttrInfo;
|
||||
use dom_struct::dom_struct;
|
||||
|
@ -99,6 +98,7 @@ use crate::dom::bindings::xmlname::{
|
|||
};
|
||||
use crate::dom::characterdata::CharacterData;
|
||||
use crate::dom::create::create_element;
|
||||
use crate::dom::csp::{CspReporting, InlineCheckType};
|
||||
use crate::dom::customelementregistry::{
|
||||
CallbackReaction, CustomElementDefinition, CustomElementReaction, CustomElementState,
|
||||
is_valid_custom_element_name,
|
||||
|
@ -2259,15 +2259,19 @@ impl Element {
|
|||
} else {
|
||||
let win = self.owner_window();
|
||||
let source = &**attr.value();
|
||||
let global = &self.owner_global();
|
||||
// However, if the Should element's inline behavior be blocked by
|
||||
// Content Security Policy? algorithm returns "Blocked" when executed
|
||||
// upon the attribute's element, "style attribute", and the attribute's value,
|
||||
// then the style rules defined in the attribute's value must not be applied to the element. [CSP]
|
||||
if doc.should_elements_inline_type_behavior_be_blocked(
|
||||
self,
|
||||
csp::InlineCheckType::StyleAttribute,
|
||||
source,
|
||||
) == csp::CheckResult::Blocked
|
||||
if global
|
||||
.get_csp_list()
|
||||
.should_elements_inline_type_behavior_be_blocked(
|
||||
global,
|
||||
self,
|
||||
InlineCheckType::StyleAttribute,
|
||||
source,
|
||||
)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue