1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 11:18:13 +00:00

LibXML: Prevent entering the root node of an SVG document twice

Currently, if an SVG document is parsed, we enter the root <svg> element
twice - first when its node is appended, and then immediately after the
call to append its node. Prevent this by only ever entering nodes from
the appropriate location inside the call to append the node.
This commit is contained in:
Timothy Flynn 2023-06-08 11:33:24 -04:00 committed by Andreas Kling
parent 71b184accf
commit b6228507ac

View file

@ -71,7 +71,9 @@ size_t Parser::s_debug_indent_level { 0 };
void Parser::append_node(NonnullOwnPtr<Node> node)
{
if (m_entered_node) {
m_entered_node->content.get<Node::Element>().children.append(move(node));
auto& entered_element = m_entered_node->content.get<Node::Element>();
entered_element.children.append(move(node));
enter_node(*entered_element.children.last());
} else {
m_root_node = move(node);
enter_node(*m_root_node);
@ -620,7 +622,6 @@ ErrorOr<void, ParseError> Parser::parse_element()
auto& node = *start_tag;
auto& tag = node.content.get<Node::Element>();
append_node(move(start_tag));
enter_node(node);
ScopeGuard quit {
[&] {
leave_node();