Repository navigation
Conversation
WP_Font_Face::compile_variations() writes each axis as
sprintf( '"%s" %s', $tag, $value ) since r63653. Neither part is
escaped or validated, so a tag holding `"` ends the string early and
the rest of the tag and the value are written as CSS:
array( 'wght' => 400 ) -> "wght" 400
array( 'wg"t' => 400 ) -> "wg"t" 400
The tag is written with WP_CSS_Builder::string(), and an axis is
skipped unless its tag is four characters from U+0020 to U+007E, as
CSS Fonts 4 requires, and its value reads as one CSS number token.
Values such as `400px` or `calc(400)` are skipped; the descriptor
takes a <number>, and calc() is the only other form CSS accepts there.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
…ont-variation-tags
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.
Caution
This is a work in progress draft and is not ready for any serious review.
WP_Font_Face::compile_variations()writes each axis of afont-variation-settingsarray assprintf( '"%s" %s', $tag, $value )since r63653 (https://core.trac.wordpress.org/ticket/66103). The tag is put in quotes without escaping and the value is not checked, so a tag with a quotation mark ends the string early:array( 'wght' => 400 )"wght" 400"wght" 400array( 'wg"t' => 400 )"wg"t" 400"wg\22 t" 400array( 'wght' => '400px' )"wght" 400pxThe tag is written with
WP_CSS_Builder::string(). An axis is skipped unless its tag is four characters from U+0020 to U+007E, which CSS Fonts 4 requires of an axis tag, and its value is one CSS number token, read withWP_CSS_Token_Processor. When every axis is skipped, the descriptor is omitted.A value such as
calc(400)is valid CSS for the descriptor but is skipped; the array form is a PHP API, and numbers are what callers pass.WordPress#13610 does not change
compile_variations().The string form of
font-variation-settingsand the other@font-facedescriptors are written as they are; this PR does not change them.Depends on WordPress#14781.
Trac ticket: TBD
Use of AI Tools
AI assistance: Yes
Tools: Claude Code
Models: Claude Opus 5.5
Used for: implementation, tests and this description.
This pull request is for code review only. Keep other discussion in the Trac ticket. Do not merge. See GitHub Pull Requests for Code Review in the Core Handbook.