瀏覽代碼

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 年之前
父節點
當前提交
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)
 {
     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();