Fix external stream-codecs consumers to use bounded vendored JBIG2

This commit is contained in:
Dylan M. Taylor
2026-11-15 14:31:01 -05:00
parent 7d39dc4df2
commit 201601fa2d
2 changed files with 12 additions and 2 deletions
+3 -2
View File
@@ -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]
+9
View File
@@ -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<Vec<u8>, CodecError> {
let mut unbounded = u64::MAX;