summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-05-07 06:43:22 +0200
committerAndreas Kling <kling@serenityos.org>2023-05-07 09:06:48 +0200
commitaf5d892a7e2dc44f8c6b4ff3e3397903a9bcc9e1 (patch)
treea49495329b053a96bb4970513a944814bbc47938
parenteadef3e5c31a38f33e43a3d86456c90d93f04623 (diff)
downloadserenity-af5d892a7e2dc44f8c6b4ff3e3397903a9bcc9e1.zip
Ladybird: Don't ask Qt to decode SVG images for us
While it's nice to see <img src="foo.svg"> suddenly work in Ladybird after linking with the Qt SVG module, this is cheating. We should implement SVG-as-image ourselves instead of relying on 3rd party code to do it. :^)
-rw-r--r--Ladybird/ImageCodecPluginLadybird.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/Ladybird/ImageCodecPluginLadybird.cpp b/Ladybird/ImageCodecPluginLadybird.cpp
index 0172d2d384..054a343391 100644
--- a/Ladybird/ImageCodecPluginLadybird.cpp
+++ b/Ladybird/ImageCodecPluginLadybird.cpp
@@ -72,6 +72,12 @@ Optional<Web::Platform::DecodedImage> ImageCodecPluginLadybird::decode_image(Rea
auto image = decode_image_with_libgfx(data);
if (image.has_value())
return image;
+
+ // NOTE: Even though Qt can decode SVG images for us, let's not do that.
+ // We should handle <img src="foo.svg"> ourselves instead of cheating by using Qt.
+ if (data.starts_with("<?xml"sv.bytes()) || data.starts_with("<svg"sv.bytes()))
+ return {};
+
return decode_image_with_qt(data);
}