mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-24 19:21:52 +00:00
LibWeb: Reject selectors with named namespaces in querySelectorAll
This commit is contained in:
parent
ba0cc7fe46
commit
bb678e75f9
Notes:
github-actions[bot]
2024-11-23 08:51:25 +00:00
Author: https://github.com/Gingeh
Commit: bb678e75f9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2478
Reviewed-by: https://github.com/AtkinsSJ
2 changed files with 46 additions and 22 deletions
|
@ -23,6 +23,26 @@ namespace Web::DOM {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(ParentNode);
|
||||
|
||||
static bool contains_named_namespace(const CSS::SelectorList& selectors)
|
||||
{
|
||||
for (auto const& selector : selectors) {
|
||||
for (auto const& compound_selector : selector->compound_selectors()) {
|
||||
for (auto simple_selector : compound_selector.simple_selectors) {
|
||||
if (simple_selector.value.has<CSS::Selector::SimpleSelector::QualifiedName>()) {
|
||||
if (simple_selector.qualified_name().namespace_type == CSS::Selector::SimpleSelector::QualifiedName::NamespaceType::Named)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (simple_selector.value.has<CSS::Selector::SimpleSelector::PseudoClassSelector>()) {
|
||||
if (contains_named_namespace(simple_selector.pseudo_class().argument_selector_list))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
enum class ReturnMatches {
|
||||
First,
|
||||
All,
|
||||
|
@ -40,6 +60,10 @@ static WebIDL::ExceptionOr<Variant<GC::Ptr<Element>, GC::Ref<NodeList>>> scope_m
|
|||
|
||||
auto selectors = maybe_selectors.value();
|
||||
|
||||
// "Note: Support for namespaces within selectors is not planned and will not be added."
|
||||
if (contains_named_namespace(selectors))
|
||||
return WebIDL::SyntaxError::create(node.realm(), "Failed to parse selector"_string);
|
||||
|
||||
// 3. Return the result of match a selector against a tree with s and node’s root using scoping root node.
|
||||
GC::Ptr<Element> single_result;
|
||||
Vector<GC::Root<Node>> results;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue