mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-29 12:38:58 -06:00
The font-metrics CMap parser (ToUnicode and embedded CID CMaps) split the stream on whitespace and sliced hex tokens as UTF-8 text: - a non-ASCII byte inside `<...>` sliced a character in half and panicked - `bfrange` arrays and `/Differences` incremented code counters past u32::MAX, and CID lookup added `c + (code - lo)` unchecked - 4 KB of overlapping `bfrange`s could ask for millions of map entries - legal CMaps with no space between tokens (`<0001><0070>`) mapped nothing, so their text was not found for editing A byte-level lexer now reads hex strings (whitespace inside allowed), brackets, names, literal strings and comments. Counters use checked or saturating arithmetic, array entries stop at the range's `hi`, and a CMap adds at most 1 Mi ToUnicode entries and 64 Ki codespace/CID ranges. A bad array entry still stands for its code, as before. Claude-Session: https://claude.ai/code/session_01VNJqS2dEQawHJn1qTRJiKp Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>