Opened 12 hours ago
Last modified 12 hours ago
#66387 new enhancement
KSES: Allow CSS color functions in inline styles
| Reported by: | aaronrobertshaw | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.3 |
| Component: | Editor | Version: | |
| Severity: | normal | Keywords: | gutenberg-merge has-patch has-unit-tests |
| Cc: | Focuses: |
Description
Backport of Gutenberg PR https://github.com/WordPress/gutenberg/pull/84213.
safecss_filter_attr() drops any declaration whose value uses a CSS color function, such as rgb(), hsl(), oklch() or color-mix(). So box-shadow: 1px 1px 1px rgba(0,0,0,0.5) never reaches the page. The same goes for a shadow or text color from the style engine.
It removes a color function from the test string, innermost first, only when its contents are plain color syntax. Anything left over, such as a parenthesis, backslash, comment or unknown function, is still rejected. The check runs before the safecss_filter_attr_allow_css filter, so a plugin can still reject the declaration.
Change History (1)
This ticket was mentioned in PR #14973 on WordPress/wordpress-develop by @aaronrobertshaw.
12 hours ago
#1
- Keywords has-patch has-unit-tests added
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Backport of Gutenberg PR https://github.com/WordPress/gutenberg/pull/84213
Trac ticket: https://core.trac.wordpress.org/ticket/66387
safecss_filter_attr()drops any declaration that uses a CSS color function, such asrgba()in abox-shadow. This keeps a color function when its contents are plain color syntax.This PR backports:
safecss_filter_attr(), alongside the existingvar(),calc()and similar handling,safecss_filter_attr_allow_cssfilter still rejecting the result.The Gutenberg PR added this as a filter. In Core it is part of the function itself, so the filter sees the result of the check.
Testing instructions
npm run test:php -- --group 66387.Use of AI
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: The mechanical port and tests; I reviewed and edited them.