KSES: Allow filter function values in inline styles. - #13039
KSES: Allow filter function values in inline styles.#13039jigneshbhavani wants to merge 1 commit into
Conversation
The `filter` property has been allowlisted since [52049], and [55564] made `url()` values survive, but the CSS filter functions were never added to the function-stripping expression, so every functional value was dropped in full. `hue-rotate()` was the sole exception, and only because `\brotate(` matches inside it after the transform functions were added in [63180]. Follow-up to [63180]. See #65871.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the 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. |
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
filterhas been in thesafecss_filter_attr()property allowlist since [52049], and[55564] made
url()values survive, but the CSS filter functions were never added to thefunction-stripping expression at
wp-includes/kses.php:3018. A declaration using one stillcontains a
(when it reaches the check below it, so it is dropped in full and the propertyis unusable in its canonical form for anyone without
unfiltered_html.Measured on trunk at [63180], PHP 8.3:
filter: blur(5px)filter: brightness(0.4)filter: contrast(200%)filter: drop-shadow(16px 16px 20px blue)filter: grayscale(50%)filter: hue-rotate(90deg)filter: invert(75%)filter: opacity(25%)filter: saturate(30%)filter: sepia(60%)filter: blur(5px) brightness(0.4)filter: url(#svg-blur)filter: nonehue-rotate()already passed, but not by design: [63180] addedrotatefor the transformfunctions and
\brotate(matches insidehue-rotate(90deg)because the hyphen is a wordboundary, leaving
filter: hue-in the test string. It is now matched by its own name.This is the same change [63180] made for the transform and basic shape functions. The value
is still re-emitted from the original declaration,
url()values still go throughwp_kses_bad_protocol(), and the test string check is unchanged, so the security model isthe same.
Not in scope:
backdrop-filteris not allowlisted at all, and the colour functionsrgb(),rgba(),hsl()andcolor-mix()are dropped everywhere, which is #56391.Testing
12 of the new cases fail on trunk without the
kses.phpchange:With the patch the full
ksesgroup is green, 487 tests / 1562 assertions, andphpcspasses on both changed files.
Trac ticket: https://core.trac.wordpress.org/ticket/65871
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: Drafting this description and a first pass at the test cases. I measured the
before and after behaviour myself, confirmed the tests fail without the patch, ran the
ksesgroup andphpcs, and I take responsibility for the change.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.