1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:18:12 +00:00

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.
This commit is contained in:
Timothy Flynn 2023-06-08 11:38:46 -04:00 committed by Andreas Kling
parent c8d8640018
commit 3a28be2a98

View file

@ -181,7 +181,7 @@ static bool build_video_document(DOM::Document& document)
bool parse_document(DOM::Document& document, ByteBuffer const& data)
{
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);
parser->run(document.url());
return true;