Skip to content

Sanitize Part I - #1934

Open
cmyr wants to merge 14 commits into
mainfrom
sanitize-v3-on-unified
Open

Sanitize Part I#1934
cmyr wants to merge 14 commits into
mainfrom
sanitize-v3-on-unified

Conversation

@cmyr

@cmyr cmyr commented Jun 21, 2026

Copy link
Copy Markdown
Member

this PR is based on #1924

This adds the Sanitize trait, and generates impls for a bunch of our test inputs.

The sanitize behaviour is opt-in, and this does not opt-in for any real tables; that will happen in a follow-up.

The trait and impl are very simple; it is currently only concerned with validating table data, not dealing with things like cycle detection or mitigating DOS surface area. That work can also come as a followup.

@cmyr cmyr changed the title Sanitize v3 on unified Sanitize v3 Jun 21, 2026
@cmyr
cmyr force-pushed the sanitize-v3-on-unified branch 3 times, most recently from 9957835 to 2348a56 Compare June 21, 2026 20:23
/// Marks this field as the discriminant for a generic offset type.
pub(crate) discriminant: Option<syn::Path>,
/// During sanitize, only check the length of this field (don't recurse).
pub(crate) sanitize_len_only: Option<syn::Path>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's of any use, in HB we call this sanitize_shallow.

// only used in COLRv1
_recursion_depth: u32,
// gpos/gsub
_subtable_depth: u32,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure off the top of my head what this would be used for. For sanitizing, we don't need to recurse into lookups from contextual types. And extension lookups do not allow their contained lookup itself to be an extension. So, the tree structure in GSUB/GPOS is quite shallow and not unbounded. COLRv1 on the other hand is an unbounded graph structure.

@cmyr
cmyr force-pushed the sanitize-v3-on-unified branch 2 times, most recently from 5d81dd2 to 0775369 Compare June 22, 2026 16:35
@cmyr
cmyr force-pushed the sanitize-v3-on-unified branch from 0775369 to 82de5a5 Compare June 22, 2026 23:41
@cmyr cmyr mentioned this pull request Jun 23, 2026
@cmyr cmyr changed the title Sanitize v3 Sanitize Part I Jun 23, 2026
Base automatically changed from unify-fontread-args to main July 10, 2026 16:36
@cmyr
cmyr force-pushed the sanitize-v3-on-unified branch 3 times, most recently from 33faad7 to bcf607e Compare July 10, 2026 20:54

@dfrg dfrg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few questions but otherwise looks good!

Comment thread read-fonts/src/sanitize.rs
Comment thread read-fonts/src/sanitize.rs Outdated
Comment thread read-fonts/src/sanitize.rs Outdated
cmyr added 12 commits August 7, 2026 04:51
This is the basic API that will be used by codegen.
This sanitizes scalars, offsets, and arrays, but doesn't handle computed
arrays and various other fancy types.
sanitize offests to arrays in records
This works around #[count(..)] fields, for the time being.
Particularly make sure we handle offsets with read args, and the
sanitize_with attribute.
... If we encounter a field that we don't know how to sanitize.
cmyr added 2 commits August 7, 2026 04:51
This lets us avoid a bunch of dead code warnings.

This PR additionally adds some annotations to supress some warnings
during non-test builds, so that CI is green.
@cmyr
cmyr force-pushed the sanitize-v3-on-unified branch from bcf607e to 087a830 Compare August 7, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants