Skip to content

Commit 6d13811

Browse files
KSES: Allow filter property to accept a URL in safecss_filter_attr().
CSS filters can accept `url()` as a reference to an SVG filter element: {{{ filter: url( file.svg#filter-element-id ); }}} This commit allows for that syntax to be used in inline CSS. Original PR from Gutenberg repository: * [WordPress/gutenberg#48281 #48281 Duotone: Use the style engine to generate CSS for Duotone] References: * [https://developer.mozilla.org/en-US/docs/Web/CSS/filter MDN Web Docs: filter()] * [https://developer.mozilla.org/en-US/docs/Web/CSS/url MDN Web Docs: url()] Follow-up to [44136], [52049]. Props scruffian, jeryj, ironprogrammer, azaozz, hellofromTonya, SergeyBiryukov. Fixes #57780. git-svn-id: https://develop.svn.wordpress.org/trunk@55564 602fd350-edb4-49c9-b593-d223f7449a82
1 parent a387dee commit 6d13811

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

‎src/wp-includes/kses.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2279,6 +2279,7 @@ function kses_init() {
22792279
* Extended `margin-*` and `padding-*` support for logical properties.
22802280
* @since 6.2.0 Added support for `aspect-ratio`, `position`, `top`, `right`, `bottom`, `left`,
22812281
* and `z-index` CSS properties.
2282+
* @since 6.3.0 Extended support for `filter` to accept a URL.
22822283
*
22832284
* @param string $css A string of CSS rules.
22842285
* @param string $deprecated Not used.
@@ -2466,6 +2467,7 @@ function safecss_filter_attr( $css, $deprecated = '' ) {
24662467
'background-image',
24672468

24682469
'cursor',
2470+
'filter',
24692471

24702472
'list-style',
24712473
'list-style-image',

‎tests/phpunit/tests/kses.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,11 @@ public function data_safecss_filter_attr() {
13161316
'css' => 'aspect-ratio: url( https://wordpress.org/wp-content/uploads/aspect-ratio.jpg );',
13171317
'expected' => '',
13181318
),
1319+
// URL support for `filter` introduced in 6.3.
1320+
array(
1321+
'css' => 'filter: url( my-file.svg#svg-blur );',
1322+
'expected' => 'filter: url( my-file.svg#svg-blur )',
1323+
),
13191324
);
13201325
}
13211326

0 commit comments

Comments
 (0)