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>
This commit is contained in:
Charan Rathore
2026-10-18 13:34:49 +05:30
parent e704504204
commit e08950c8e6
2 changed files with 12 additions and 1 deletions
+12
View File
@@ -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
-1
View File
@@ -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;
}