From b9e6f1835079745cadd232272666282ec0b58f26 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Sat, 18 May 2019 04:33:27 +0000 Subject: [PATCH] KSES: Add `flex` and related long form properties to safe CSS. Allow `flex`, `flex-grow`, `flex-shrink` and `flex-basis` to be used in inline CSS. As of WordPress 5.3 the block editor is expected to use `flex-basis` inline to set the width in the column block. Props aduth. Fixes #47281. See #37248. git-svn-id: https://develop.svn.wordpress.org/trunk@45363 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/kses.php | 6 ++++++ tests/phpunit/tests/kses.php | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/wp-includes/kses.php b/src/wp-includes/kses.php index 2b96e84a47..d73c5e8ff1 100644 --- a/src/wp-includes/kses.php +++ b/src/wp-includes/kses.php @@ -2063,6 +2063,7 @@ function safecss_filter_attr( $css, $deprecated = '' ) { * @since 5.0.0 Added support for `background-image`. * @since 5.1.0 Added support for `text-transform`. * @since 5.2.0 Added support for `background-position` and `grid-template-columns` + * @since 5.3.0 Added support for `flex`, `flex-grow`, `flex-shrink`, and `flex-basis`. * * @param string[] $attr Array of allowed CSS attributes. */ @@ -2133,6 +2134,11 @@ function safecss_filter_attr( $css, $deprecated = '' ) { 'padding-left', 'padding-top', + 'flex', + 'flex-grow', + 'flex-shrink', + 'flex-basis', + 'clear', 'cursor', 'direction', diff --git a/tests/phpunit/tests/kses.php b/tests/phpunit/tests/kses.php index b359452b88..98c2987c2e 100644 --- a/tests/phpunit/tests/kses.php +++ b/tests/phpunit/tests/kses.php @@ -830,6 +830,11 @@ EOF; 'css' => 'background: green url("foo.jpg") no-repeat fixed center', 'expected' => 'background: green url("foo.jpg") no-repeat fixed center', ), + // `flex` and related attributes introduced in 5.3. + array( + 'css' => 'flex: 0 1 auto;flex-basis: 75%;flex-shrink: 0;flex-grow: 1', + 'expected' => 'flex: 0 1 auto;flex-basis: 75%;flex-shrink: 0;flex-grow: 1', + ), ); }