Make WordPress Core

Changeset 55944


Ignore:
Timestamp:
06/20/2023 02:29:18 AM (15 months ago)
Author:
peterwilsoncc
Message:

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.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/kses.php

    r55937 r55944  
    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.
     2282 * @since 6.3.0 Extended support for `filter` to accept a URL and added support for repeat().
    22832283 *
    22842284 * @param string $css        A string of CSS rules.
     
    25642564             */
    25652565            $css_test_string = preg_replace(
    2566                 '/\b(?:var|calc|min|max|minmax|clamp)(\((?:[^()]|(?1))*\))/',
     2566                '/\b(?:var|calc|min|max|minmax|clamp|repeat)(\((?:[^()]|(?1))*\))/',
    25672567                '',
    25682568                $css_test_string
  • trunk/tests/phpunit/tests/kses.php

    r55822 r55944  
    938938     * @ticket 55966
    939939     * @ticket 56122
     940     * @ticket 58551
    940941     * @dataProvider data_safecss_filter_attr
    941942     *
     
    10481049                'expected' => 'grid-template-rows: 40px 4em 40px;grid-auto-rows: min-content;grid-row-start: -1;grid-row-end: 3;grid-row-gap: 1em',
    10491050            ),
    1050             // `grid` does not yet support functions or `\`.
    1051             array(
    1052                 'css'      => 'grid-template-columns: repeat(2, 50px 1fr);grid-template: 1em / 20% 20px 1fr',
     1051            // `grid` does not yet support `\`.
     1052            array(
     1053                'css'      => 'grid-template: 1em / 20% 20px 1fr',
    10531054                'expected' => '',
    10541055            ),
     
    13211322                'css'      => 'filter: url( my-file.svg#svg-blur );',
    13221323                'expected' => 'filter: url( my-file.svg#svg-blur )',
     1324            ),
     1325            // Support for `repeat` function.
     1326            array(
     1327                'css'      => 'grid-template-columns: repeat(4, minmax(0, 1fr))',
     1328                'expected' => 'grid-template-columns: repeat(4, minmax(0, 1fr))',
     1329            ),
     1330            array(
     1331                'css'      => 'grid-template-columns: repeat(auto-fill, minmax(min(12rem, 100%), 1fr))',
     1332                'expected' => 'grid-template-columns: repeat(auto-fill, minmax(min(12rem, 100%), 1fr))',
     1333            ),
     1334            // Malformed repeat, no closing `)`.
     1335            array(
     1336                'css'      => 'grid-template-columns: repeat(4, minmax(0, 1fr)',
     1337                'expected' => '',
     1338            ),
     1339            // Malformed repeat, contains unsupported function.
     1340            array(
     1341                'css'      => 'grid-template-columns: repeat(4, unsupported(0, 1fr)',
     1342                'expected' => '',
    13231343            ),
    13241344        );
Note: See TracChangeset for help on using the changeset viewer.