Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

fix(fonts): update wuff to handle corrupt WOFF2 data

ldm08c8169beddc7
diff --git a/Cargo.lock b/Cargo.lock
index 683d0081e..97091259f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -23,15 +23,6 @@ version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3"
-[[package]]
-name = "alloc-stdlib"
-version = "0.2.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0e76a019e91224d279006ff972f1e984179a6e9feb050adba6ce8274aef23195"
-dependencies = [
- "alloc-no-stdlib",
-]
-
[[package]]
name = "allocator-api2"
version = "0.2.21"
@@ -378,7 +369,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a32acac15fe1967bc3986b2a6347dffc965602354ea6f450ad07e8bfd253583"
dependencies = [
"alloc-no-stdlib",
- "alloc-stdlib",
]
[[package]]
@@ -6207,11 +6197,10 @@ checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc"
[[package]]
name = "wuff"
-version = "0.2.5"
+version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d77cd3107d02dc860d9377a7e28a60e2a77c6d1964f4119999b03dd95f007719"
+checksum = "200a7b806377b65f1ff9a985874332f15357c87e5dd7855f35f06dade95b8b3d"
dependencies = [
- "arrayvec",
"brotli-decompressor",
"bytes",
"flate2",
diff --git a/moli-layout/Cargo.toml b/moli-layout/Cargo.toml
index 6a3bfec64..900311b10 100644
--- a/moli-layout/Cargo.toml
+++ b/moli-layout/Cargo.toml
@@ -14,7 +14,7 @@ stylo = "0.20"
stylo_taffy = { git = "https://github.com/DioxusLabs/blitz", rev = "5081c65811a4396f5a99b2e0aca542a4a4a6606f", default-features = false, features = ["std", "block", "flexbox", "grid", "floats"] }
taffy = { version = "=0.13.0", default-features = false, features = ["std", "block_layout", "flexbox", "grid", "float_layout", "content_size", "calc", "detailed_layout_info"] }
thiserror = "2.0.17"
-wuff = "=0.2.5"
+wuff = "0.2.9"
[lints]
workspace = true
diff --git a/moli-layout/src/text.rs b/moli-layout/src/text.rs
index c12304b4b..5e04e4863 100644
--- a/moli-layout/src/text.rs
+++ b/moli-layout/src/text.rs
@@ -1273,6 +1273,29 @@ mod tests {
assert_eq!(services.web_font_count(), 1);
}
+ #[test]
+ fn corrupt_woff2_returns_decode_error_and_preserves_existing_font() {
+ let mut services =
+ DocumentLayoutServices::with_system_font_policy(SystemFontPolicy::Disabled);
+ services
+ .register_web_font(registration("woff2-slot", "Stable Alias", TEST_WOFF2))
+ .unwrap();
+ assert!(has_family(&mut services, "Stable Alias"));
+
+ let mut corrupt_font = TEST_WOFF2.to_vec();
+ // This fixture's Brotli stream occupies bytes 76..649. Preserve its
+ // header and table directory so the failure comes from decompression.
+ assert_eq!(&corrupt_font[20..24], &573_u32.to_be_bytes());
+ corrupt_font[76..649].fill(0);
+ assert_eq!(
+ services.register_web_font(registration("woff2-slot", "Broken Alias", &corrupt_font,)),
+ Err(WebFontRegistrationError::DecodeFailed { format: "WOFF2" })
+ );
+ assert!(has_family(&mut services, "Stable Alias"));
+ assert!(!has_family(&mut services, "Broken Alias"));
+ assert_eq!(services.web_font_count(), 1);
+ }
+
#[test]
fn unchanged_registration_does_not_rebuild_and_remove_is_explicit() {
let mut services =
diff --git a/moli-renderer-v8/Cargo.toml b/moli-renderer-v8/Cargo.toml
index d1def308a..b9f38b59d 100644
--- a/moli-renderer-v8/Cargo.toml
+++ b/moli-renderer-v8/Cargo.toml
@@ -130,7 +130,7 @@ moli-page-types = { path = "../moli-page-types", features = ["test-support"] }
moli-v8-test-util = { path = "../moli-v8-test-util" }
moli-websocket = { path = "../moli-websocket", features = ["test-support"] }
png = "0.18"
-wuff = "=0.2.5"
+wuff = "0.2.9"
[lints]
workspace = true