mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 20:17:42 +00:00
LibWeb: Support X-Content-Type-Options to opt out of MIME type sniffing
This commit is contained in:
parent
0681086cad
commit
076cd58817
1 changed files with 6 additions and 1 deletions
|
@ -81,9 +81,14 @@ void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, const HashMap
|
|||
} else if (url().protocol() == "data" && !url().data_mime_type().is_empty()) {
|
||||
dbgln_if(RESOURCE_DEBUG, "This is a data URL with mime-type _{}_", url().data_mime_type());
|
||||
m_mime_type = url().data_mime_type();
|
||||
} else {
|
||||
auto content_type_options = headers.get("X-Content-Type-Options");
|
||||
if (content_type_options.value_or("").equals_ignoring_case("nosniff")) {
|
||||
m_mime_type = "text/plain";
|
||||
} else {
|
||||
m_mime_type = Core::guess_mime_type_based_on_filename(url().path());
|
||||
}
|
||||
}
|
||||
|
||||
m_encoding = {};
|
||||
if (content_type.has_value()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue