From 201601fa2d5dab0f1aa0e6f2581751bac088a495 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 15 Nov 2026 14:31:01 -0500 Subject: [PATCH] Fix external stream-codecs consumers to use bounded vendored JBIG2 --- crates/stream-codecs/Cargo.toml | 5 +++-- crates/stream-codecs/src/jbig2/decode.rs | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/stream-codecs/Cargo.toml b/crates/stream-codecs/Cargo.toml index 8827f294e..14ce68603 100644 --- a/crates/stream-codecs/Cargo.toml +++ b/crates/stream-codecs/Cargo.toml @@ -15,8 +15,9 @@ workspace = true fax = "0.2.7" # CCITT fax decoding, the decoder the vendored PDF reader uses. MIT OR Apache-2.0. hayro-ccitt = { version = "0.3", default-features = false } -# JBIG2 decoding, the decoder the vendored PDF reader uses (the workspace patches it to `vendor/hayro-jbig2`). -hayro-jbig2 = { version = "=0.3.0", default-features = false, features = ["std"] } +# The bounded JBIG2 API is a local extension: consumers do not inherit workspace patches. +# Keep the vendored dependency explicit so Git consumers retain its work-budget safeguards. +hayro-jbig2 = { path = "../../vendor/hayro-jbig2", version = "=0.3.0", default-features = false, features = ["std"] } thiserror = { workspace = true } [dev-dependencies] diff --git a/crates/stream-codecs/src/jbig2/decode.rs b/crates/stream-codecs/src/jbig2/decode.rs index e5a49d359..0e04bd648 100644 --- a/crates/stream-codecs/src/jbig2/decode.rs +++ b/crates/stream-codecs/src/jbig2/decode.rs @@ -78,6 +78,15 @@ mod tests { use super::*; use crate::{encode_jbig2, encode_jbig2_generic}; + /// A registry fallback lacks the budget APIs and breaks consumers outside this workspace. + #[test] + fn bounded_decoder_dependency_is_explicit_for_external_consumers() { + let manifest = include_str!("../../Cargo.toml"); + let dependency = manifest.lines().find(|line| line.starts_with("hayro-jbig2 =")).unwrap(); + assert!(dependency.contains(r#"path = "../../vendor/hayro-jbig2""#)); + assert!(dependency.contains(r#"version = "=0.3.0""#)); + } + /// [`decode_jbig2_within`] with no limit on the work. fn decode_jbig2(data: &[u8], globals: Option<&[u8]>, columns: u32, rows: u32, max: usize) -> Result, CodecError> { let mut unbounded = u64::MAX;