Repository navigation
fix(font): validate SFNT character map ranges - #1056
Merged
Merged
Conversation
andiwand
force-pushed
the
review/37-legacy-metadata
branch
from
October 5, 2026 09:53
f6a86bf to
1a5830a
Compare
A PDF addresses the glyphs of an embedded font by ID, so a refused font falls back to a substitute and shows the wrong glyphs. Like FreeType, a broken cmap subtable now drops only itself, and the next supported one is used. A bad format-4 segment is skipped. A table or name that runs past its end is clipped, an odd UTF-16 name length and a duplicate table tag are accepted. A table offset past the end and a zero unitsPerEm still throw. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gb1fLafqqzehpqPuU6uBfn
andiwand
force-pushed
the
review/38-sfnt-cmap-bounds
branch
from
October 5, 2026 11:03
e1ebcf7 to
f470f38
Compare
andiwand
commented
Oct 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Generated with Claude Code
A malformed format-12 character-map range could wrap indefinitely or expand overlapping ranges repeatedly. The parser now checks character and glyph ranges before it expands them. Like FreeType, a broken or unsupported cmap subtable drops only itself, and the next supported one is used, because a PDF addresses embedded glyphs by ID. A table or name that runs past its end is clipped; a table offset past the end and a zero em size throw.
Keep accepting the unused format-4 terminator offset found in an existing embedded-font fixture. The constraints follow the OpenType cmap specification.
Validation: 60 targeted font/PDF-font tests and three PDF corpus cases pass, with no font parsing warnings. Three focused regression tests cover malformed input and supported-subtable selection.