Skip to content

Commit f9367a5

Browse files
trflynn89awesomekling
authored andcommitted
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.
1 parent d744f04 commit f9367a5

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Userland/Libraries/LibWeb/HTML/HTMLObjectElement.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,20 @@ void HTMLObjectElement::resource_did_load()
165165
}
166166
// * Otherwise, if the resource does not have associated Content-Type metadata
167167
else {
168-
String tentative_type;
168+
Optional<String> tentative_type;
169169

170170
// 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.
171171
// Otherwise, let tentative type be the computed type of the resource.
172172
if (auto type = this->type(); !type.is_empty())
173173
tentative_type = move(type);
174-
else
175-
tentative_type = resource()->mime_type();
174+
175+
// FIXME: For now, ignore application/ MIME types as we cannot render yet them anyways. We will need to implement the MIME type sniffing
176+
// algorithm in order to map all unknown MIME types to "application/octet-stream".
177+
else if (auto type = resource()->mime_type(); !type.starts_with("application/"))
178+
tentative_type = move(type);
176179

177180
// 2. If tentative type is not application/octet-stream, then let resource type be tentative type and jump to the step below labeled handler.
178-
if (tentative_type != "application/octet-stream"sv)
181+
if (tentative_type.has_value() && tentative_type != "application/octet-stream"sv)
179182
resource_type = move(tentative_type);
180183
}
181184

0 commit comments

Comments
 (0)