From 830f1dbbfe24cc3d2155954d05a603815309d517 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sat, 7 Oct 2023 14:45:28 +0330 Subject: [PATCH] LibWeb/XML: Do not create text nodes for empty text chunks This corresponds to the empty text node between foo and bar in ``, which is not supposed to become a text node in HTML. --- Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp index 6961e1470a..c58a687e3c 100644 --- a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp +++ b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp @@ -146,8 +146,10 @@ void XMLDocumentBuilder::text(StringView data) auto string = DeprecatedString::empty(); if (!data.is_null()) string = data.to_deprecated_string(); - auto node = m_document->create_text_node(MUST(String::from_deprecated_string(string))); - MUST(m_current_node->append_child(node)); + if (!string.is_empty()) { + auto node = m_document->create_text_node(MUST(String::from_deprecated_string(string))); + MUST(m_current_node->append_child(node)); + } } }