Make WordPress Core


Ignore:
Timestamp:
02/15/2023 03:55:12 AM (10 months ago)
Author:
peterwilsoncc
Message:

Editor: Prevent KSES stripping global layout style properties.

Layout style properties are stored using indirect values, rather than direct CSS properties.

Allow users without the unfiltered_html capability to modify global styles using the indirect block spacing properties contentSize, wideSize, and blockGap, using a mapping of the eventual CSS property to the indirect property stored in theme.json. The mapped CSS property is then used for CSS validation.

Props andrewserong, costdev, hellofromtonya, mamaduka, mmtr86.
Fixes #57321.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/theme/wpThemeJson.php

    r55285 r55345  
    24282428
    24292429    /**
     2430     * @ticket 57321
     2431     *
     2432     * @covers WP_Theme_JSON::remove_insecure_properties
     2433     */
     2434    public function test_remove_insecure_properties_should_allow_indirect_properties() {
     2435        $actual = WP_Theme_JSON::remove_insecure_properties(
     2436            array(
     2437                'version'  => WP_Theme_JSON::LATEST_SCHEMA,
     2438                'styles'   => array(
     2439                    'spacing' => array(
     2440                        'blockGap' => '3em',
     2441                    ),
     2442                    'blocks'  => array(
     2443                        'core/social-links' => array(
     2444                            'spacing' => array(
     2445                                'blockGap' => array(
     2446                                    'left' => '2em',
     2447                                    'top'  => '1em',
     2448                                ),
     2449                            ),
     2450                        ),
     2451                    ),
     2452                ),
     2453                'settings' => array(
     2454                    'layout' => array(
     2455                        'contentSize' => '800px',
     2456                        'wideSize'    => '1000px',
     2457                    ),
     2458                ),
     2459            )
     2460        );
     2461
     2462        $expected = array(
     2463            'version'  => WP_Theme_JSON::LATEST_SCHEMA,
     2464            'styles'   => array(
     2465                'spacing' => array(
     2466                    'blockGap' => '3em',
     2467                ),
     2468                'blocks'  => array(
     2469                    'core/social-links' => array(
     2470                        'spacing' => array(
     2471                            'blockGap' => array(
     2472                                'left' => '2em',
     2473                                'top'  => '1em',
     2474                            ),
     2475                        ),
     2476                    ),
     2477                ),
     2478            ),
     2479            'settings' => array(
     2480                'layout' => array(
     2481                    'contentSize' => '800px',
     2482                    'wideSize'    => '1000px',
     2483                ),
     2484            ),
     2485        );
     2486
     2487        $this->assertSameSetsWithIndex( $expected, $actual );
     2488    }
     2489
     2490    /**
    24302491     * @ticket 56467
    24312492     */
Note: See TracChangeset for help on using the changeset viewer.