mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
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:
commit
785fcd5580
5 changed files with 37 additions and 2 deletions
|
@ -16,6 +16,7 @@ azure = {git = "https://github.com/servo/rust-azure", features = ["plugins"]}
|
||||||
bitflags = "0.7"
|
bitflags = "0.7"
|
||||||
euclid = "0.10.1"
|
euclid = "0.10.1"
|
||||||
fnv = "1.0"
|
fnv = "1.0"
|
||||||
|
fontsan = {git = "https://github.com/servo/fontsan"}
|
||||||
gfx_traits = {path = "../gfx_traits"}
|
gfx_traits = {path = "../gfx_traits"}
|
||||||
harfbuzz-sys = "0.1"
|
harfbuzz-sys = "0.1"
|
||||||
heapsize = "0.3.0"
|
heapsize = "0.3.0"
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use font_template::{FontTemplate, FontTemplateDescriptor};
|
use font_template::{FontTemplate, FontTemplateDescriptor};
|
||||||
|
use fontsan;
|
||||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||||
use ipc_channel::router::ROUTER;
|
use ipc_channel::router::ROUTER;
|
||||||
use mime::{TopLevel, SubLevel};
|
use mime::{TopLevel, SubLevel};
|
||||||
|
@ -252,8 +253,18 @@ impl FontCache {
|
||||||
channel_to_self.send(msg).unwrap();
|
channel_to_self.send(msg).unwrap();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let mut bytes = bytes.lock().unwrap();
|
let bytes = mem::replace(&mut *bytes.lock().unwrap(), vec![]);
|
||||||
let bytes = mem::replace(&mut *bytes, Vec::new());
|
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 =
|
let command =
|
||||||
Command::AddDownloadedWebFont(family_name.clone(),
|
Command::AddDownloadedWebFont(family_name.clone(),
|
||||||
url.clone(),
|
url.clone(),
|
||||||
|
|
|
@ -39,6 +39,7 @@ extern crate fnv;
|
||||||
// Platforms that use Freetype/Fontconfig library dependencies
|
// Platforms that use Freetype/Fontconfig library dependencies
|
||||||
#[cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))]
|
#[cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))]
|
||||||
extern crate fontconfig;
|
extern crate fontconfig;
|
||||||
|
extern crate fontsan;
|
||||||
#[cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))]
|
#[cfg(any(target_os = "linux", target_os = "android", all(target_os = "windows", target_env = "gnu")))]
|
||||||
extern crate freetype;
|
extern crate freetype;
|
||||||
|
|
||||||
|
|
11
components/servo/Cargo.lock
generated
11
components/servo/Cargo.lock
generated
|
@ -689,6 +689,16 @@ name = "fnv"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
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]]
|
[[package]]
|
||||||
name = "freetype"
|
name = "freetype"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -758,6 +768,7 @@ dependencies = [
|
||||||
"core-text 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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)",
|
"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)",
|
"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)",
|
"freetype 0.1.0 (git+https://github.com/servo/rust-freetype)",
|
||||||
"gfx_traits 0.0.1",
|
"gfx_traits 0.0.1",
|
||||||
"harfbuzz-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"harfbuzz-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
11
ports/cef/Cargo.lock
generated
11
ports/cef/Cargo.lock
generated
|
@ -606,6 +606,16 @@ name = "fnv"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
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]]
|
[[package]]
|
||||||
name = "freetype"
|
name = "freetype"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -675,6 +685,7 @@ dependencies = [
|
||||||
"core-text 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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)",
|
"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)",
|
"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)",
|
"freetype 0.1.0 (git+https://github.com/servo/rust-freetype)",
|
||||||
"gfx_traits 0.0.1",
|
"gfx_traits 0.0.1",
|
||||||
"harfbuzz-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"harfbuzz-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue