Sanitize Part I - #1934
Open
cmyr wants to merge 14 commits into
Open
Conversation
cmyr
force-pushed
the
sanitize-v3-on-unified
branch
3 times, most recently
from
June 21, 2026 20:23
9957835 to
2348a56
Compare
behdad
reviewed
Jun 22, 2026
| /// 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>, |
Contributor
There was a problem hiding this comment.
If it's of any use, in HB we call this sanitize_shallow.
behdad
reviewed
Jun 22, 2026
| // only used in COLRv1 | ||
| _recursion_depth: u32, | ||
| // gpos/gsub | ||
| _subtable_depth: u32, |
Contributor
There was a problem hiding this comment.
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
force-pushed
the
sanitize-v3-on-unified
branch
2 times, most recently
from
June 22, 2026 16:35
5d81dd2 to
0775369
Compare
cmyr
force-pushed
the
sanitize-v3-on-unified
branch
from
June 22, 2026 23:41
0775369 to
82de5a5
Compare
cmyr
force-pushed
the
sanitize-v3-on-unified
branch
3 times, most recently
from
July 10, 2026 20:54
33faad7 to
bcf607e
Compare
dfrg
approved these changes
Jul 13, 2026
dfrg
left a comment
Contributor
There was a problem hiding this comment.
A few questions but otherwise looks good!
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.
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
force-pushed
the
sanitize-v3-on-unified
branch
from
August 7, 2026 09:06
bcf607e to
087a830
Compare
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.
this PR is based on #1924
This adds the
Sanitizetrait, 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.