Make WordPress Core

Changeset 62530


Ignore:
Timestamp:
06/19/2026 06:41:13 AM (8 weeks ago)
Author:
wildworks
Message:

KSES: Allow SVG presentation attributes in safe_style_css.

Add SVG presentation attributes to the list of CSS properties allowed by safecss_filter_attr(), so inline SVG markup can be styled via the style attribute.

This ports Gutenberg PR #79172 to Core.

Props afercia, westonruter, wildworks.
Fixes #65457.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/kses.php

    r62433 r62530  
    25802580         *
    25812581         * @since 2.8.1
     2582         * @since 7.1.0 Added support for SVG presentation attributes.
    25822583         *
    25832584         * @param string[] $attr Array of allowed CSS attributes.
     
    27382739                        'container-type',
    27392740
     2741                        'fill',
     2742                        'fill-opacity',
     2743                        'fill-rule',
     2744
     2745                        'stroke',
     2746                        'stroke-dasharray',
     2747                        'stroke-dashoffset',
     2748                        'stroke-linecap',
     2749                        'stroke-linejoin',
     2750                        'stroke-miterlimit',
     2751                        'stroke-opacity',
     2752                        'stroke-width',
     2753
     2754                        'color-interpolation',
     2755                        'color-interpolation-filters',
     2756                        'paint-order',
     2757                        'stop-color',
     2758                        'stop-opacity',
     2759                        'flood-color',
     2760                        'flood-opacity',
     2761                        'lighting-color',
     2762
     2763                        'marker',
     2764                        'marker-end',
     2765                        'marker-mid',
     2766                        'marker-start',
     2767
     2768                        'clip-path',
     2769                        'clip-rule',
     2770                        'mask',
     2771                        'mask-type',
     2772
     2773                        'cx',
     2774                        'cy',
     2775                        'r',
     2776                        'rx',
     2777                        'ry',
     2778                        'x',
     2779                        'y',
     2780                        'd',
     2781
     2782                        'alignment-baseline',
     2783                        'baseline-shift',
     2784                        'dominant-baseline',
     2785                        'glyph-orientation-horizontal',
     2786                        'glyph-orientation-vertical',
     2787                        'text-anchor',
     2788                        'unicode-bidi',
     2789                        'word-spacing',
     2790
     2791                        'font-size-adjust',
     2792                        'font-stretch',
     2793
     2794                        'color-rendering',
     2795                        'image-rendering',
     2796                        'shape-rendering',
     2797                        'text-rendering',
     2798                        'vector-effect',
     2799
     2800                        'transform',
     2801                        'transform-origin',
     2802
     2803                        'pointer-events',
     2804                        'visibility',
     2805
    27402806                        // Custom CSS properties.
    27412807                        '--*',
  • trunk/tests/phpunit/tests/kses.php

    r62433 r62530  
    10011001         * @ticket 60132
    10021002         * @ticket 64414
     1003         * @ticket 65457
    10031004         *
    10041005         * @dataProvider data_safecss_filter_attr
     
    14731474                                'css'      => 'display: grid',
    14741475                                'expected' => 'display: grid',
     1476                        ),
     1477                        // SVG presentation attributes introduced in 7.1.0.
     1478                        array(
     1479                                'css'      => 'fill: none',
     1480                                'expected' => 'fill: none',
     1481                        ),
     1482                        array(
     1483                                'css'      => 'fill-rule: evenodd',
     1484                                'expected' => 'fill-rule: evenodd',
     1485                        ),
     1486                        array(
     1487                                'css'      => 'stroke: red',
     1488                                'expected' => 'stroke: red',
     1489                        ),
     1490                        array(
     1491                                'css'      => 'stroke-width: 2',
     1492                                'expected' => 'stroke-width: 2',
     1493                        ),
     1494                        array(
     1495                                'css'      => 'stroke-linecap: round',
     1496                                'expected' => 'stroke-linecap: round',
     1497                        ),
     1498                        array(
     1499                                'css'      => 'paint-order: stroke',
     1500                                'expected' => 'paint-order: stroke',
     1501                        ),
     1502                        array(
     1503                                'css'      => 'vector-effect: non-scaling-stroke',
     1504                                'expected' => 'vector-effect: non-scaling-stroke',
     1505                        ),
     1506                        array(
     1507                                'css'      => 'clip-rule: evenodd',
     1508                                'expected' => 'clip-rule: evenodd',
     1509                        ),
     1510                        array(
     1511                                'css'      => 'text-anchor: middle',
     1512                                'expected' => 'text-anchor: middle',
    14751513                        ),
    14761514                );
Note: See TracChangeset for help on using the changeset viewer.