Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions src/wp-includes/kses.php
Original file line number Diff line number Diff line change
Expand Up @@ -2579,6 +2579,7 @@ function safecss_filter_attr( $css, $deprecated = '' ) {
* Filters the list of allowed CSS attributes.
*
* @since 2.8.1
* @since 7.1.0 Added support for SVG presentation attributes.
*
* @param string[] $attr Array of allowed CSS attributes.
*/
Expand Down Expand Up @@ -2737,6 +2738,55 @@ function safecss_filter_attr( $css, $deprecated = '' ) {
'aspect-ratio',
'container-type',

'fill',
'fill-opacity',
'fill-rule',

'stroke',
'stroke-dasharray',
'stroke-dashoffset',
'stroke-linecap',
'stroke-linejoin',
'stroke-miterlimit',
'stroke-opacity',
'stroke-width',

'color-interpolation',
'color-interpolation-filters',
'paint-order',
'stop-color',
'stop-opacity',
'flood-color',
'flood-opacity',
'lighting-color',

'marker',
'marker-start',
'marker-mid',
'marker-end',

'clip-rule',
'mask-type',

'cx',
'cy',
'r',
'rx',
'ry',
'x',
'y',
'd',

'alignment-baseline',
'baseline-shift',
'dominant-baseline',
'glyph-orientation-horizontal',
'glyph-orientation-vertical',
'text-anchor',

'shape-rendering',
'vector-effect',

// Custom CSS properties.
'--*',
)
Expand Down
38 changes: 38 additions & 0 deletions tests/phpunit/tests/kses.php
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,7 @@ public function test_wp_kses_attr_no_attributes_allowed_with_false() {
* @ticket 58551
* @ticket 60132
* @ticket 64414
* @ticket 65457
*
* @dataProvider data_safecss_filter_attr
*
Expand Down Expand Up @@ -1473,6 +1474,43 @@ public function data_safecss_filter_attr() {
'css' => 'display: grid',
'expected' => 'display: grid',
),
// SVG presentation attributes introduced in 7.1.0.
array(
'css' => 'fill: none',
'expected' => 'fill: none',
),
array(
'css' => 'fill-rule: evenodd',
'expected' => 'fill-rule: evenodd',
),
array(
'css' => 'stroke: red',
'expected' => 'stroke: red',
),
array(
'css' => 'stroke-width: 2',
'expected' => 'stroke-width: 2',
),
array(
'css' => 'stroke-linecap: round',
'expected' => 'stroke-linecap: round',
),
array(
'css' => 'paint-order: stroke',
'expected' => 'paint-order: stroke',
),
array(
'css' => 'vector-effect: non-scaling-stroke',
'expected' => 'vector-effect: non-scaling-stroke',
),
array(
'css' => 'clip-rule: evenodd',
'expected' => 'clip-rule: evenodd',
),
array(
'css' => 'text-anchor: middle',
'expected' => 'text-anchor: middle',
),
);
}

Expand Down
Loading