aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-08-22 19:20:19 -0500
committerGitHub <noreply@github.com>2016-08-22 19:20:19 -0500
commit785fcd55806b546e2d5d15d5618fdf575262a012 (patch)
treef4bb34c1e7b2fcddc72c31c89265dfd97a969069
parent7aa0071e9b59db792742e1a47bd8577764a89fa7 (diff)
parent6cbf9e75dffe3c8e74f6f067abe6967c45c692f1 (diff)
downloadservo-785fcd55806b546e2d5d15d5618fdf575262a012.tar.gz
servo-785fcd55806b546e2d5d15d5618fdf575262a012.zip
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 -->
-rw-r--r--components/gfx/Cargo.toml1
-rw-r--r--components/gfx/font_cache_thread.rs15
-rw-r--r--components/gfx/lib.rs1
-rw-r--r--components/servo/Cargo.lock11
-rw-r--r--ports/cef/Cargo.lock11
5 files changed, 37 insertions, 2 deletions
diff --git a/components/gfx/Cargo.toml b/components/gfx/Cargo.toml
index bc8adf69204..3ef6e183239 100644
--- a/components/gfx/Cargo.toml
+++ b/components/gfx/Cargo.toml
@@ -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"
diff --git a/components/gfx/font_cache_thread.rs b/components/gfx/font_cache_thread.rs
index 9b761900a80..055216a948d 100644
--- a/components/gfx/font_cache_thread.rs
+++ b/components/gfx/font_cache_thread.rs
@@ -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(),
diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs
index bed633b9562..f8e8febc96c 100644
--- a/components/gfx/lib.rs
+++ b/components/gfx/lib.rs
@@ -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;
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock
index 2d8398feda0..cebdd269793 100644
--- a/components/servo/Cargo.lock
+++ b/components/servo/Cargo.lock
@@ -690,6 +690,16 @@ 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"
source = "git+https://github.com/servo/rust-freetype#d564ff90a3c69d987f5c015d7ec034cfaee21aff"
@@ -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)",
diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock
index 341e24b7b19..1045d09c615 100644
--- a/ports/cef/Cargo.lock
+++ b/ports/cef/Cargo.lock
@@ -607,6 +607,16 @@ 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"
source = "git+https://github.com/servo/rust-freetype#d564ff90a3c69d987f5c015d7ec034cfaee21aff"
@@ -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)",