Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore the Content-Type header completely for @font-face. #13931

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -25,7 +25,6 @@ ipc-channel = "0.5"
lazy_static = "0.2"
libc = "0.2"
log = "0.3.5"
mime = "0.2"
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
ordered-float = "0.2.2"
@@ -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 {
@@ -62,7 +62,6 @@ extern crate lazy_static;
extern crate libc;
#[macro_use]
extern crate log;
extern crate mime;
extern crate msg;
extern crate net_traits;
extern crate ordered_float;
@@ -1,3 +1,2 @@
[mime_sniffing_font_context.html]
type: testharness
prefs: [network.mime.sniff:true]
@@ -51,8 +51,8 @@
var xhr = new XMLHttpRequest();
xhr.open('GET', 'resources/no_mime_type.py?Content-Type=application/xhtml%2Bxml', true);
xhr.onload = this.step_func_done(function() {
t4.step_timeout(checkFontNotLoaded.bind(t4, 'fifth', 'sixth'), 500);
assert_equals(xhr.getResponseHeader('Content-Type'), 'application/xhtml+xml');
t4.step_timeout(checkFontLoaded, 500);
});
xhr.send();
}, "XHR Content-Type has xhtml+xml");
@@ -61,8 +61,8 @@
var xhr = new XMLHttpRequest();
xhr.open('GET', 'resources/no_mime_type.py?Content-Type=application/xml', true);
xhr.onload = this.step_func_done(function() {
t3.step_timeout(checkFontNotLoaded.bind(t3, 'third', 'fourth'), 500);
assert_equals(xhr.getResponseHeader('Content-Type'), 'application/xml');
t3.step_timeout(checkFontLoaded, 500);
});
xhr.send();
}, "XHR Content-Type has xml");
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.