From 6d1381180b0d90ef606d5c9d2afa3c4234726a76 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 20 Mar 2023 08:23:47 +0000 Subject: [PATCH] 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: * [https://github.com/WordPress/gutenberg/pull/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 --- src/wp-includes/kses.php | 2 ++ tests/phpunit/tests/kses.php | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/wp-includes/kses.php b/src/wp-includes/kses.php index 8722176718..6bbb7c977d 100644 --- a/src/wp-includes/kses.php +++ b/src/wp-includes/kses.php @@ -2279,6 +2279,7 @@ function kses_init() { * Extended `margin-*` and `padding-*` support for logical properties. * @since 6.2.0 Added support for `aspect-ratio`, `position`, `top`, `right`, `bottom`, `left`, * and `z-index` CSS properties. + * @since 6.3.0 Extended support for `filter` to accept a URL. * * @param string $css A string of CSS rules. * @param string $deprecated Not used. @@ -2466,6 +2467,7 @@ function safecss_filter_attr( $css, $deprecated = '' ) { 'background-image', 'cursor', + 'filter', 'list-style', 'list-style-image', diff --git a/tests/phpunit/tests/kses.php b/tests/phpunit/tests/kses.php index dcef22c44c..db5e26ec0b 100644 --- a/tests/phpunit/tests/kses.php +++ b/tests/phpunit/tests/kses.php @@ -1316,6 +1316,11 @@ EOF; 'css' => 'aspect-ratio: url( https://wordpress.org/wp-content/uploads/aspect-ratio.jpg );', 'expected' => '', ), + // URL support for `filter` introduced in 6.3. + array( + 'css' => 'filter: url( my-file.svg#svg-blur );', + 'expected' => 'filter: url( my-file.svg#svg-blur )', + ), ); }