Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/wp-includes/kses.php
Original file line number Diff line number Diff line change
Expand Up @@ -2279,7 +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.
* @since 6.3.0 Extended support for `filter` to accept a URL and added support for repeat().
*
* @param string $css A string of CSS rules.
* @param string $deprecated Not used.
Expand Down Expand Up @@ -2563,7 +2563,7 @@ function safecss_filter_attr( $css, $deprecated = '' ) {
* Nested functions and parentheses are also removed, so long as the parentheses are balanced.
*/
$css_test_string = preg_replace(
'/\b(?:var|calc|min|max|minmax|clamp)(\((?:[^()]|(?1))*\))/',
'/\b(?:var|calc|min|max|minmax|clamp|repeat)(\((?:[^()]|(?1))*\))/',
'',
$css_test_string
);
Expand Down
24 changes: 22 additions & 2 deletions tests/phpunit/tests/kses.php
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,7 @@ public function test_wp_kses_attr_no_attributes_allowed_with_false() {
* @ticket 48376
* @ticket 55966
* @ticket 56122
* @ticket 58551
* @dataProvider data_safecss_filter_attr
*
* @param string $css A string of CSS rules.
Expand Down Expand Up @@ -1047,9 +1048,9 @@ public function data_safecss_filter_attr() {
'css' => 'grid-template-rows: 40px 4em 40px;grid-auto-rows: min-content;grid-row-start: -1;grid-row-end: 3;grid-row-gap: 1em',
'expected' => 'grid-template-rows: 40px 4em 40px;grid-auto-rows: min-content;grid-row-start: -1;grid-row-end: 3;grid-row-gap: 1em',
),
// `grid` does not yet support functions or `\`.
// `grid` does not yet support `\`.
array(
'css' => 'grid-template-columns: repeat(2, 50px 1fr);grid-template: 1em / 20% 20px 1fr',
'css' => 'grid-template: 1em / 20% 20px 1fr',
'expected' => '',
),
// `flex` and `grid` alignments introduced in 5.3.
Expand Down Expand Up @@ -1321,6 +1322,25 @@ public function data_safecss_filter_attr() {
'css' => 'filter: url( my-file.svg#svg-blur );',
'expected' => 'filter: url( my-file.svg#svg-blur )',
),
// Support for `repeat` function.
array(
'css' => 'grid-template-columns: repeat(4, minmax(0, 1fr))',
'expected' => 'grid-template-columns: repeat(4, minmax(0, 1fr))',
),
array(
'css' => 'grid-template-columns: repeat(auto-fill, minmax(min(12rem, 100%), 1fr))',
'expected' => 'grid-template-columns: repeat(auto-fill, minmax(min(12rem, 100%), 1fr))',
),
// Malformed repeat, no closing `)`.
array(
'css' => 'grid-template-columns: repeat(4, minmax(0, 1fr)',
'expected' => '',
),
// Malformed repeat, contains unsupported function.
array(
'css' => 'grid-template-columns: repeat(4, unsupported(0, 1fr)',
'expected' => '',
),
);
}

Expand Down