Repository navigation
Conversation
Most CSS grammars allow whitespace and comments between component values, so every consumer that reads a value skips both token types. The parser-based safecss_filter_attr() defines its own helper for this, and the font-family and selector-list consumers need the same test.
Font family lists, selector lists and several property values are comma-separated lists of component values. Core splits them with explode( ',' ) or with scanners that track some nesting, which split inside strings, escapes, comments or blocks. The method follows the CSS Syntax 3 algorithm and returns the tokens of each group. A comma at the end of the input produces a final empty group, which the algorithm omits, because the font-family and selector grammars reject a trailing comma and a caller cannot otherwise detect one. Blocks are not nested in the result; a caller that needs them reads the function and bracket tokens in order.
|
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:
|
This was referenced Nov 17, 2026
…omma-separated-lists
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.
Add two helpers to the CSS API for reading comma-separated values:
WP_CSS_Token::is_whitespace_or_comment()reports whether a token is whitespace or a comment. Most grammars allow both between component values, so every value reader skips them. The parser-basedsafecss_filter_attr()(KSES: Parse declarations in safecss_filter_attr() WordPress/wordpress-develop#14784) defines a private copy,_safecss_filter_attr_is_trivia().WP_CSS_Token_Processor::parse_comma_separated_list( $css )returns the tokens of each group between top-level commas. A comma inside a string, comment, escape, function,(),[]or{}block stays in its group.Font family lists and selector lists are comma-separated, and core splits them with
explode( ',' )or with scanners that track some of these cases:explode( ',' )parse_comma_separated_list()"Foo, Bar", serif"Foo,Bar",serif"Foo, Bar",serif:is(a, b) img, c:is(a,b) img,c:is(a, b) img,cThe method follows the CSS Syntax 3 algorithm with one difference: a comma at the end of the input produces a final empty group. The font-family and selector grammars reject a trailing comma, and the algorithm's result does not show one. Blocks are not nested in the result; their tokens appear in order.
The font-family and selector-list alternatives stacked on this branch are the first consumers.
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.