Skip to content

Commit 171a547

Browse files
Formatting: Add 'white-space' as an allowed KSES CSS attribute.
The 'white-space' attribute is safe, has wide browser support, and is useful. Props sukhendu2002, mukesh27, whyisjake.. Fixes #51707. git-svn-id: https://develop.svn.wordpress.org/trunk@60671 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d68b516 commit 171a547

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/wp-includes/kses.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,6 +2418,7 @@ function kses_init() {
24182418
* @since 6.4.0 Added support for `writing-mode`.
24192419
* @since 6.5.0 Added support for `background-repeat`.
24202420
* @since 6.6.0 Added support for `grid-column`, `grid-row`, and `container-type`.
2421+
* @since 6.9.0 Added support for `white-space`.
24212422
*
24222423
* @param string $css A string of CSS rules.
24232424
* @param string $deprecated Not used.
@@ -2510,6 +2511,7 @@ function safecss_filter_attr( $css, $deprecated = '' ) {
25102511
'text-decoration',
25112512
'text-indent',
25122513
'text-transform',
2514+
'white-space',
25132515

25142516
'height',
25152517
'min-height',

tests/phpunit/tests/kses.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,23 @@ public function data_safecss_filter_attr() {
11801180
'css' => 'object-fit: cover',
11811181
'expected' => 'object-fit: cover',
11821182
),
1183+
// `white-space` introduced in 6.9.0.
1184+
array(
1185+
'css' => 'white-space: nowrap',
1186+
'expected' => 'white-space: nowrap',
1187+
),
1188+
array(
1189+
'css' => 'white-space: pre',
1190+
'expected' => 'white-space: pre',
1191+
),
1192+
array(
1193+
'css' => 'white-space: pre-wrap',
1194+
'expected' => 'white-space: pre-wrap',
1195+
),
1196+
array(
1197+
'css' => 'white-space: pre-line',
1198+
'expected' => 'white-space: pre-line',
1199+
),
11831200
// Expressions are not allowed.
11841201
array(
11851202
'css' => 'height: expression( body.scrollTop + 50 + "px" )',

0 commit comments

Comments
 (0)