Make WordPress Core

Changeset 54102


Ignore:
Timestamp:
09/08/2022 03:04:39 PM (22 months ago)
Author:
SergeyBiryukov
Message:

KSES: Allow more layout-related CSS properties.

Adds support for the following CSS properties considered safe for inline CSS:

  • flex-wrap
  • gap
  • column-gap
  • row-gap

Extends support for margin and padding to include logical properties:

  • margin-block-start
  • margin-block-end
  • margin-inline-start
  • margin-inline-end
  • padding-block-start
  • padding-block-end
  • padding-inline-start
  • padding-inline-end

Follow-up to [46235].

Props andrewserong, peterwilsoncc, ramonopoly, bernhard-reiter.
Fixes #56122.

Location:
trunk
Files:
2 edited

Legend:

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

    r54100 r54102  
    22252225 * @since 5.2.0 Added support for `background-position` and `grid-template-columns`.
    22262226 * @since 5.3.0 Added support for `grid`, `flex` and `column` layout properties.
    2227  *              Extend `background-*` support of individual properties.
     2227 *              Extended `background-*` support for individual properties.
    22282228 * @since 5.3.1 Added support for gradient backgrounds.
    22292229 * @since 5.7.1 Added support for `object-position`.
     
    22312231 * @since 6.1.0 Added support for `min()`, `max()`, `minmax()`, `clamp()`,
    22322232 *              and nested `var()` values.
     2233 *              Added support for `gap`, `column-gap`, `row-gap`, and `flex-wrap`.
     2234 *              Extended `margin-*` and `padding-*` support for logical properties.
    22332235 *
    22342236 * @param string $css        A string of CSS rules.
     
    23362338            'margin-left',
    23372339            'margin-top',
     2340            'margin-block-start',
     2341            'margin-block-end',
     2342            'margin-inline-start',
     2343            'margin-inline-end',
    23382344
    23392345            'padding',
     
    23422348            'padding-left',
    23432349            'padding-top',
     2350            'padding-block-start',
     2351            'padding-block-end',
     2352            'padding-inline-start',
     2353            'padding-inline-end',
    23442354
    23452355            'flex',
     
    23492359            'flex-grow',
    23502360            'flex-shrink',
     2361            'flex-wrap',
     2362
     2363            'gap',
     2364            'column-gap',
     2365            'row-gap',
    23512366
    23522367            'grid-template-columns',
  • trunk/tests/phpunit/tests/kses.php

    r54100 r54102  
    937937     * @ticket 48376
    938938     * @ticket 55966
     939     * @ticket 56122
    939940     * @dataProvider data_test_safecss_filter_attr
    940941     *
     
    10351036            // `flex` and related attributes introduced in 5.3.
    10361037            array(
    1037                 'css'      => 'flex: 0 1 auto;flex-basis: 75%;flex-direction: row-reverse;flex-flow: row-reverse nowrap;flex-grow: 2;flex-shrink: 1',
    1038                 'expected' => 'flex: 0 1 auto;flex-basis: 75%;flex-direction: row-reverse;flex-flow: row-reverse nowrap;flex-grow: 2;flex-shrink: 1',
     1038                'css'      => 'flex: 0 1 auto;flex-basis: 75%;flex-direction: row-reverse;flex-flow: row-reverse nowrap;flex-grow: 2;flex-shrink: 1;flex-wrap: nowrap',
     1039                'expected' => 'flex: 0 1 auto;flex-basis: 75%;flex-direction: row-reverse;flex-flow: row-reverse nowrap;flex-grow: 2;flex-shrink: 1;flex-wrap: nowrap',
    10391040            ),
    10401041            // `grid` and related attributes introduced in 5.3.
     
    12361237                'css'      => 'width: (3em + (10px * 2))',
    12371238                'expected' => '',
     1239            ),
     1240            // Gap introduced in 6.1.
     1241            array(
     1242                'css'      => 'gap: 10px;column-gap: 5px;row-gap: 20px',
     1243                'expected' => 'gap: 10px;column-gap: 5px;row-gap: 20px',
     1244            ),
     1245            // Margin and padding logical properties introduced in 6.1.
     1246            array(
     1247                'css'      => 'margin-block-start: 1px;margin-block-end: 2px;margin-inline-start: 3px;margin-inline-end: 4px;padding-block-start: 1px;padding-block-end: 2px;padding-inline-start: 3px;padding-inline-end: 4px',
     1248                'expected' => 'margin-block-start: 1px;margin-block-end: 2px;margin-inline-start: 3px;margin-inline-end: 4px;padding-block-start: 1px;padding-block-end: 2px;padding-inline-start: 3px;padding-inline-end: 4px',
    12381249            ),
    12391250        );
Note: See TracChangeset for help on using the changeset viewer.