Skip to content

KSES: Allow box-sizing in safecss_filter_attr() - #14708

Draft
draganescu wants to merge 1 commit into
WordPress:trunkfrom
draganescu:add/safe-style-css-box-sizing
Draft

draganescu wants to merge 1 commit into
WordPress:trunkfrom
draganescu:add/safe-style-css-box-sizing

Conversation

@draganescu

Copy link
Copy Markdown

Adds box-sizing to the CSS properties safecss_filter_attr() allows. Backport of Gutenberg #85373.

The layout block support gives a block with a fixed width in a Row or Stack (selfStretch: fixed with a flexSize) flex-basis and box-sizing: border-box, so its padding and borders stay inside the width set (wp_get_child_layout_style_rules() in block-supports/layout.php). The style engine filters every declaration through safecss_filter_attr(), and box-sizing isn't on its list, so the declaration is silently dropped and a padded fixed-width block ends up wider than the width set. Gutenberg's manual grid free placement (experimental) also relies on it.

Adds a box-sizing: border-box case to Tests_Kses::data_safecss_filter_attr().

Trac ticket:

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Writing the change, the test and this description, reviewed by me.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

🤖 Generated with Claude Code

The layout block support gives a child with a fixed size in a flex layout
`box-sizing: border-box`, but the style engine filters every declaration
through `safecss_filter_attr()`, which dropped it.

Synced from WordPress/gutenberg#85373.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

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.

1 participant