mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-28 20:18:06 -06:00
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:
Vendored
+12
@@ -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
|
||||
|
||||
Vendored
-1
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user