Opened 13 hours ago
Last modified 13 hours ago
#66427 new defect (bug)
Block Supports: Allow CSS custom properties in wp_sanitize_block_gap_value()
| Reported by: | noruzzaman | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Editor | Version: | trunk |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: | css, tests |
Description
When a theme defines a preset block gap in theme.json (such as styles.spacing.blockGap: "var:preset|spacing|32"):
- wp_get_global_styles() resolves the preset to its CSS variable format: var(--wp--preset--spacing--32).
- Candidate values for the global block gap in layout rendering are passed through wp_sanitize_block_gap_value().
- Because wp_sanitize_block_gap_value() disallows parentheses to prevent CSS injection, the resolved preset is rejected and returns null.
- As a result, Grid layout calculations in wp_get_layout_style() fall back to 0.5em instead of using the theme's preset gap value.
- In Grid blocks with columnCount and minimumColumnWidth, columns stack into a single column.
Fix: Allow valid CSS custom property references matching /^var\(--[a-zA-Z0-9_-]+\)$/.
Gutenberg PR: https://github.com/WordPress/gutenberg/pull/82817
Change History (1)
This ticket was mentioned in PR #15277 on WordPress/wordpress-develop by @noruzzaman.
13 hours ago
#1
- Keywords has-patch has-unit-tests added
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Gutenberg PR: https://github.com/WordPress/gutenberg/pull/82817
Description
Allows valid CSS custom property references (such as
var(--wp--preset--spacing--32)) inwp_sanitize_block_gap_value().When a theme defines a preset block gap in
theme.json(such asstyles.spacing.blockGap: "var:preset|spacing|32"):wp_get_global_styles()resolves the preset to its CSS variable format:var(--wp--preset--spacing--32).wp_sanitize_block_gap_value().wp_sanitize_block_gap_value()disallows parentheses to prevent CSS injection, the resolved preset was rejected and returnednull.wp_get_layout_style()fell back to0.5eminstead of using the theme's preset gap value.columnCountandminimumColumnWidth, columns stack into a single column.Testing Instructions