From 888e139a9413a6bd2c9864e2c4f4ab67a667797f Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Wed, 1 Feb 2023 22:50:11 +0000 Subject: [PATCH] KSES: Allow position-related CSS properties. Adds support for the following CSS properties considered safe for inline CSS: * `position` * `top` * `right` * `bottom` * `left` * `z-index` References: * [https://github.com/WordPress/gutenberg/pull/46142 Gutenberg PR 46142]. Follow-up to [54117]. Props andrewserong, mukesh27. Fixes #57504. git-svn-id: https://develop.svn.wordpress.org/trunk@55184 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/kses.php | 8 ++++++++ tests/phpunit/tests/kses.php | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/wp-includes/kses.php b/src/wp-includes/kses.php index 157be6be11..5766beb92f 100644 --- a/src/wp-includes/kses.php +++ b/src/wp-includes/kses.php @@ -2277,6 +2277,7 @@ function kses_init() { * nested `var()` values, and assigning values to CSS variables. * Added support for `object-fit`, `gap`, `column-gap`, `row-gap`, and `flex-wrap`. * Extended `margin-*` and `padding-*` support for logical properties. + * @since 6.2.0 Added support for `position`, `top`, `right`, `bottom`, `left` and `z-index` position CSS properties. * * @param string $css A string of CSS rules. * @param string $deprecated Not used. @@ -2438,6 +2439,13 @@ function safecss_filter_attr( $css, $deprecated = '' ) { 'overflow', 'vertical-align', + 'position', + 'top', + 'right', + 'bottom', + 'left', + 'z-index', + // Custom CSS properties. '--*', ) diff --git a/tests/phpunit/tests/kses.php b/tests/phpunit/tests/kses.php index 8843903aff..7e72817c7b 100644 --- a/tests/phpunit/tests/kses.php +++ b/tests/phpunit/tests/kses.php @@ -1278,6 +1278,11 @@ EOF; 'css' => '--?><.%-not-allowed: red;', 'expected' => '', ), + // Position properties introduced in 6.2. + array( + 'css' => 'position: sticky;top: 0;left: 0;right: 0;bottom: 0;z-index: 10;', + 'expected' => 'position: sticky;top: 0;left: 0;right: 0;bottom: 0;z-index: 10', + ), ); }