From f9367a5fdbc530791f01132ad03b0dfe118e4d66 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 24 Mar 2022 11:39:49 -0400 Subject: [PATCH] LibWeb: Ignore application objects until we can support them The HTMLObjectElement spec is set up to ignore application/octet-stream MIME types only. For this to work, we need to implement the MIME type sniffing algorithm so that all unknown MIME types become mapped to the application/octet-stream type. Until then, ignore all application/ MIME types as we won't be able to display them anyways. --- Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp index 2203681f9e..c922f82b3a 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp @@ -165,17 +165,20 @@ void HTMLObjectElement::resource_did_load() } // * Otherwise, if the resource does not have associated Content-Type metadata else { - String tentative_type; + Optional tentative_type; // 1. If there is a type attribute present on the object element, then let the tentative type be the type specified in that type attribute. // Otherwise, let tentative type be the computed type of the resource. if (auto type = this->type(); !type.is_empty()) tentative_type = move(type); - else - tentative_type = resource()->mime_type(); + + // FIXME: For now, ignore application/ MIME types as we cannot render yet them anyways. We will need to implement the MIME type sniffing + // algorithm in order to map all unknown MIME types to "application/octet-stream". + else if (auto type = resource()->mime_type(); !type.starts_with("application/")) + tentative_type = move(type); // 2. If tentative type is not application/octet-stream, then let resource type be tentative type and jump to the step below labeled handler. - if (tentative_type != "application/octet-stream"sv) + if (tentative_type.has_value() && tentative_type != "application/octet-stream"sv) resource_type = move(tentative_type); }