Auto merge of #12938 - nox:fontsan, r=larsbergstrom

Sanitise web fonts

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12938)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-08-22 19:20:19 -05:00 committed by GitHub
commit 785fcd5580
5 changed files with 37 additions and 2 deletions

View file

@ -16,6 +16,7 @@ azure = {git = "https://github.com/servo/rust-azure", features = ["plugins"]}
bitflags = "0.7"
euclid = "0.10.1"
fnv = "1.0"
fontsan = {git = "https://github.com/servo/fontsan"}
gfx_traits = {path = "../gfx_traits"}
harfbuzz-sys = "0.1"
heapsize = "0.3.0"

View file

@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use font_template::{FontTemplate, FontTemplateDescriptor};
use fontsan;
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use ipc_channel::router::ROUTER;
use mime::{TopLevel, SubLevel};
@ -252,8 +253,18 @@ impl FontCache {
channel_to_self.send(msg).unwrap();
return;
}
let mut bytes = bytes.lock().unwrap();
let bytes = mem::replace(&mut *bytes, Vec::new());
let bytes = mem::replace(&mut *bytes.lock().unwrap(), vec![]);
let bytes = match fontsan::process(&bytes) {
Ok(san) => san,
Err(_) => {
// FIXME(servo/fontsan#1): get an error message
debug!("Sanitiser rejected web font: \
family={:?} url={}", family_name, url);
let msg = Command::AddWebFont(family_name.clone(), sources.clone(), sender.clone());
channel_to_self.send(msg).unwrap();
return;
},
};
let command =
Command::AddDownloadedWebFont(family_name.clone(),
url.clone(),

View file

@ -39,6 +39,7 @@ extern crate fnv;
// Platforms that use Freetype/Fontconfig library dependencies
#[cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))]
extern crate fontconfig;
extern crate fontsan;
#[cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))]
extern crate freetype;

View file

@ -689,6 +689,16 @@ name = "fnv"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "fontsan"
version = "0.3.2"
source = "git+https://github.com/servo/fontsan#08bfa604bf0cc882d9b4385c57db65e200975b72"
dependencies = [
"cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
"miniz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "freetype"
version = "0.1.0"
@ -758,6 +768,7 @@ dependencies = [
"core-text 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"fontsan 0.3.2 (git+https://github.com/servo/fontsan)",
"freetype 0.1.0 (git+https://github.com/servo/rust-freetype)",
"gfx_traits 0.0.1",
"harfbuzz-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",

11
ports/cef/Cargo.lock generated
View file

@ -606,6 +606,16 @@ name = "fnv"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "fontsan"
version = "0.3.2"
source = "git+https://github.com/servo/fontsan#08bfa604bf0cc882d9b4385c57db65e200975b72"
dependencies = [
"cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
"miniz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "freetype"
version = "0.1.0"
@ -675,6 +685,7 @@ dependencies = [
"core-text 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"fontsan 0.3.2 (git+https://github.com/servo/fontsan)",
"freetype 0.1.0 (git+https://github.com/servo/rust-freetype)",
"gfx_traits 0.0.1",
"harfbuzz-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",