mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:08:11 +00:00
LibWeb: Detect when an XML document belongs in the SVG namespace
We currently parse all XML documents as belonging in the HTML namespace. Switch to the SVG namespace when parsing an SVG document.
This commit is contained in:
parent
b6228507ac
commit
c8d8640018
2 changed files with 14 additions and 4 deletions
|
@ -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<DeprecatedString> resolve_xml_resource(XML::SystemID const&, Optional<XML::PublicID> const& public_id)
|
||||
|
@ -58,13 +56,23 @@ void XMLDocumentBuilder::element_start(const XML::Name& name, HashMap<XML::Name,
|
|||
|
||||
// FIXME: This should not live here at all.
|
||||
if (auto it = attributes.find("xmlns"); it != attributes.end()) {
|
||||
if (name == HTML::TagNames::html && it->value != 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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue