mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibWeb: Look at both namespace & tag name in HTML parser stack checks
We were neglecting to check the namespace when looking for a specific type of element on the stack of open elements in many cases. This caused us to confuse HTML and SVG elements.
This commit is contained in:
parent
7d7f8f1b48
commit
ceedfb34d2
Notes:
github-actions[bot]
2024-11-05 11:30:21 +00:00
Author: https://github.com/awesomekling
Commit: ceedfb34d2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2161
4 changed files with 24 additions and 18 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/HTML/Parser/HTMLParser.h>
|
||||
#include <LibWeb/HTML/Parser/StackOfOpenElements.h>
|
||||
#include <LibWeb/Namespace.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -105,10 +106,12 @@ bool StackOfOpenElements::contains(const DOM::Element& element) const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool StackOfOpenElements::contains(FlyString const& tag_name) const
|
||||
bool StackOfOpenElements::contains_template_element() const
|
||||
{
|
||||
for (auto& element_on_stack : m_elements) {
|
||||
if (element_on_stack->local_name() == tag_name)
|
||||
for (auto const& element : m_elements) {
|
||||
if (element->namespace_uri() != Namespace::HTML)
|
||||
continue;
|
||||
if (element->local_name() == HTML::TagNames::template_)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -116,7 +119,7 @@ bool StackOfOpenElements::contains(FlyString const& tag_name) const
|
|||
|
||||
void StackOfOpenElements::pop_until_an_element_with_tag_name_has_been_popped(FlyString const& tag_name)
|
||||
{
|
||||
while (m_elements.last()->local_name() != tag_name)
|
||||
while (m_elements.last()->namespace_uri() != Namespace::HTML || m_elements.last()->local_name() != tag_name)
|
||||
(void)pop();
|
||||
(void)pop();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue