mirror of
https://github.com/servo/servo.git
synced 2025-08-09 23:45:35 +01:00
Ignore the Content-Type header completely for @font-face.
This matches the previous default (network.mime.sniff off) behaviour in all but one case: we will now accept a font without a `Content-Type` header, which would previously have been ignored.
This commit is contained in:
parent
cff0f01c70
commit
44c80d5b18
7 changed files with 3 additions and 43 deletions
|
@ -6,7 +6,6 @@ use font_template::{FontTemplate, FontTemplateDescriptor};
|
|||
use fontsan;
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||
use ipc_channel::router::ROUTER;
|
||||
use mime::{TopLevel, SubLevel};
|
||||
use net_traits::{AsyncResponseTarget, LoadContext, CoreResourceThread, ResponseAction, load_async};
|
||||
use platform::font_context::FontContextHandle;
|
||||
use platform::font_list::SANS_SERIF_FONT_FAMILY;
|
||||
|
@ -25,7 +24,6 @@ use string_cache::Atom;
|
|||
use style::font_face::{EffectiveSources, Source};
|
||||
use style::properties::longhands::font_family::computed_value::FontFamily;
|
||||
use url::Url;
|
||||
use util::prefs::PREFS;
|
||||
use util::thread::spawn_named;
|
||||
use webrender_traits;
|
||||
|
||||
|
@ -227,21 +225,7 @@ impl FontCache {
|
|||
let response: ResponseAction = message.to().unwrap();
|
||||
match response {
|
||||
ResponseAction::HeadersAvailable(meta_result) => {
|
||||
let is_response_valid = match meta_result {
|
||||
Ok(ref metadata) => {
|
||||
metadata.content_type.as_ref().map_or(false, |content_type| {
|
||||
let mime = &content_type.0;
|
||||
is_supported_font_type(&(mime.0).0, &mime.1)
|
||||
})
|
||||
}
|
||||
Err(_) => false,
|
||||
};
|
||||
|
||||
info!("{} font with MIME type {}",
|
||||
if is_response_valid { "Loading" } else { "Ignoring" },
|
||||
meta_result.map(|ref meta| format!("{:?}", meta.content_type))
|
||||
.unwrap_or(format!("<Network Error>")));
|
||||
*response_valid.lock().unwrap() = is_response_valid;
|
||||
*response_valid.lock().unwrap() = meta_result.is_ok();
|
||||
}
|
||||
ResponseAction::DataAvailable(new_bytes) => {
|
||||
if *response_valid.lock().unwrap() {
|
||||
|
@ -480,25 +464,6 @@ impl FontCacheThread {
|
|||
}
|
||||
}
|
||||
|
||||
// derived from http://stackoverflow.com/a/10864297/3830
|
||||
fn is_supported_font_type(toplevel: &TopLevel, sublevel: &SubLevel) -> bool {
|
||||
if !PREFS.get("network.mime.sniff").as_boolean().unwrap_or(false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
match (toplevel, sublevel) {
|
||||
(&TopLevel::Application, &SubLevel::Ext(ref ext)) => {
|
||||
match &ext[..] {
|
||||
//FIXME: once sniffing is enabled by default, we shouldn't need nonstandard
|
||||
// MIME types here.
|
||||
"font-sfnt" | "x-font-ttf" | "x-font-truetype" | "x-font-opentype" => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Clone, Eq, PartialEq, Hash, Debug, Deserialize, Serialize)]
|
||||
pub struct LowercaseString {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue