Browse Source

LibWeb: Parse SVG document types as XML documents

We began parsing SVG documents as HTML years ago in commit 05be648. This
was long before we had an XML parser, and actually violates the spec.
Since SVG documents have a MIME type of "image/svg+xml", the spec
mandates the document should be parsed as XML.

One impact here is that the SVG document is no longer "fixed" to include
<html>, <head>, and <body> tags. This will have prevented document.title
from detecting the document element is an SVG element.
Timothy Flynn 2 years ago
parent
commit
3a28be2a98
1 changed files with 1 additions and 1 deletions
  1. 1 1
      Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp

+ 1 - 1
Userland/Libraries/LibWeb/DOM/DocumentLoading.cpp

@@ -181,7 +181,7 @@ static bool build_video_document(DOM::Document& document)
 bool parse_document(DOM::Document& document, ByteBuffer const& data)
 bool parse_document(DOM::Document& document, ByteBuffer const& data)
 {
 {
     auto& mime_type = document.content_type();
     auto& mime_type = document.content_type();
-    if (mime_type == "text/html" || mime_type == "image/svg+xml") {
+    if (mime_type == "text/html") {
         auto parser = HTML::HTMLParser::create_with_uncertain_encoding(document, data);
         auto parser = HTML::HTMLParser::create_with_uncertain_encoding(document, data);
         parser->run(document.url());
         parser->run(document.url());
         return true;
         return true;