Просмотр исходного кода

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.
Timothy Flynn 2 лет назад
Родитель
Сommit
b6228507ac
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      Userland/Libraries/LibXML/Parser/Parser.cpp

+ 3 - 2
Userland/Libraries/LibXML/Parser/Parser.cpp

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