diff --git a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp index 3bdaefa156..c80472ad2e 100644 --- a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp +++ b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp @@ -14,8 +14,6 @@ inline namespace { extern char const* s_xhtml_unified_dtd; } -static DeprecatedFlyString s_html_namespace = "http://www.w3.org/1999/xhtml"; - namespace Web { ErrorOr resolve_xml_resource(XML::SystemID const&, Optional const& public_id) @@ -58,13 +56,23 @@ void XMLDocumentBuilder::element_start(const XML::Name& name, HashMapvalue != s_html_namespace) { + if (name == HTML::TagNames::html && it->value != Namespace::HTML) { m_has_error = true; return; } + + if (name == HTML::TagNames::svg) { + if (it->value != Namespace::SVG) { + m_has_error = true; + return; + } + + m_namespace = Namespace::SVG; + } } - auto node = DOM::create_element(m_document, name, s_html_namespace).release_value_but_fixme_should_propagate_errors(); + auto node = DOM::create_element(m_document, name, m_namespace).release_value_but_fixme_should_propagate_errors(); + // When an XML parser with XML scripting support enabled creates a script element, // it must have its parser document set and its "force async" flag must be unset. // FIXME: If the parser was created as part of the XML fragment parsing algorithm, then the element must be marked as "already started" also. diff --git a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.h b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.h index 286f298e77..7f31afa625 100644 --- a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.h +++ b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.h @@ -11,6 +11,7 @@ #include #include #include +#include #include namespace Web { @@ -41,6 +42,7 @@ private: XMLScriptingSupport m_scripting_support { XMLScriptingSupport::Enabled }; bool m_has_error { false }; StringBuilder text_builder; + DeprecatedFlyString m_namespace { Namespace::HTML }; }; }