diff --git a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp index a3dc5b48ddd..d2b3c42e1d1 100644 --- a/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp +++ b/Userland/Libraries/LibWeb/XML/XMLDocumentBuilder.cpp @@ -108,8 +108,16 @@ void XMLDocumentBuilder::element_start(const XML::Name& name, HashMapset_attribute_ns(Namespace::XMLNS, MUST(FlyString::from_deprecated_fly_string(name)), MUST(String::from_byte_string(attribute.value)))); + if (!name.is_one_of("xmlns:"sv, "xmlns:xmlns"sv)) { + // The prefix xmlns is used only to declare namespace bindings and is by definition bound to the namespace name http://www.w3.org/2000/xmlns/. + MUST(node->set_attribute_ns(Namespace::XMLNS, MUST(FlyString::from_deprecated_fly_string(name)), MUST(String::from_byte_string(attribute.value)))); + } else { + m_has_error = true; + } + } else if (attribute.key.contains(":"sv)) { + if (!attribute.key.starts_with("xml:"sv)) { + m_has_error = true; + } } MUST(node->set_attribute(MUST(FlyString::from_deprecated_fly_string(attribute.key)), MUST(String::from_byte_string(attribute.value)))); }