From e08950c8e67362b0f55f5101502b985e5f870fbc Mon Sep 17 00:00:00 2001 From: Charan Rathore <180254320+charan-rathore@users.noreply.github.com> Date: Sun, 18 Oct 2026 13:34:49 +0530 Subject: [PATCH] hayro-cmap patch: truncated metadata-only streams report failure Character-collection metadata is not a mapping: a truncated stream that parsed only /Registry //Ordering //Supplement produced an empty CMap, which callers accept and which then blocks the encoding fallback paths. Drop the metadata exemption so a truncated stream with no mappings returns no CMap, exactly as a full parse failure did before. Signed-off-by: Charan Rathore <180254320+charan-rathore@users.noreply.github.com> --- vendor/hayro-cmap/src/lib.rs | 12 ++++++++++++ vendor/hayro-cmap/src/parse.rs | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/vendor/hayro-cmap/src/lib.rs b/vendor/hayro-cmap/src/lib.rs index c45cc0ae5..4eb88f505 100644 --- a/vendor/hayro-cmap/src/lib.rs +++ b/vendor/hayro-cmap/src/lib.rs @@ -1125,6 +1125,18 @@ endbfchar assert!(CMap::parse(b"<00", |_| None).is_none()); } + #[test] + fn truncated_stream_with_only_metadata_reports_failure() { + // Character-collection metadata alone is not a usable CMap: an empty + // metadata-only map would block the caller's fallback paths, so a + // truncated stream with no mappings must report failure here too. + assert!(CMap::parse( + b"/Registry (Adobe) /Ordering (Japan1) /Supplement 0 <00", + |_| None + ) + .is_none()); + } + #[test] fn bad_bfchar_code_keeps_later_entries_aligned() { // The malformed 5-byte code still has a destination object; both diff --git a/vendor/hayro-cmap/src/parse.rs b/vendor/hayro-cmap/src/parse.rs index 9450bbbe2..2a89fdbac 100644 --- a/vendor/hayro-cmap/src/parse.rs +++ b/vendor/hayro-cmap/src/parse.rs @@ -154,7 +154,6 @@ pub(crate) fn parse_inner<'a>( && notdef_ranges.is_empty() && bf_entries.is_empty() && base.is_none() - && metadata.character_collection.is_none() { return None; }