mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
KSES: Add support for CSS repeat() function.
Introduces support for the CSS `repeat()` function to support complex grid layouts. Props isabel_brison, azaozz. Fixes #58551. git-svn-id: https://develop.svn.wordpress.org/trunk@55944 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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.
|
||||
@@ -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
|
||||
);
|
||||
|
||||
@@ -937,6 +937,7 @@ EOF;
|
||||
* @ticket 48376
|
||||
* @ticket 55966
|
||||
* @ticket 56122
|
||||
* @ticket 58551
|
||||
* @dataProvider data_safecss_filter_attr
|
||||
*
|
||||
* @param string $css A string of CSS rules.
|
||||
@@ -1047,9 +1048,9 @@ EOF;
|
||||
'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.
|
||||
@@ -1321,6 +1322,25 @@ EOF;
|
||||
'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' => '',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user