A begin… block cut off at the end of the stream returned None through ? and discarded the whole map; it now ends the scan like any other unparseable tail. Test: stream_cut_off_inside_a_block_keeps_the_entries_before_it.
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>
- The truncated-stream guard was dead: completed was set on the break
path too. Detect truncation from the scanner position so a stream
that yields nothing still reports failure and callers fall back to
the font encoding.
- A skipped bfchar/bfrange entry consumed a different number of
objects than a parsed one, shifting every later pair onto the wrong
code. Skip the entry's remaining objects as well.
- A bfrange array that runs out or breaks cannot be resynced to a
member boundary; stop the loop instead of spinning over the rest of
the range.
Signed-off-by: Charan Rathore <180254320+charan-rathore@users.noreply.github.com>
A /ToUnicode CMap with any unparsable part made the reading path
discard the whole map and fall back to the font encoding, so search
and redaction missed text the edit layer could read. Vendor
hayro-cmap 0.1.0 and patch it to skip malformed bfchar/bfrange
entries, unresolvable usecmap references and unparseable tails,
keeping every readable entry, matching MuPDF/pdftotext and
PdfCraft's own edit-layer parser.
Fixes#3177.
Signed-off-by: Charan Rathore <180254320+charan-rathore@users.noreply.github.com>