Make WordPress Core

Ticket #30421: 30421.diff

File 30421.diff, 4.0 KB (added by swissspidy, 9 years ago)
  • src/wp-includes/kses.php

    diff --git src/wp-includes/kses.php src/wp-includes/kses.php
    index d34608b..5b7f9d5 100644
    function _wp_add_global_attributes( $value ) { 
    17491749        if ( true === $value )
    17501750                $value = array();
    17511751
    1752         if ( is_array( $value ) )
    1753                 return array_merge( $value, $global_attributes );
     1752        if ( is_array( $value ) ) {
     1753                return array_merge( $value, $global_attributes, _wp_get_aria_attributes() );
     1754        }
    17541755
    17551756        return $value;
    17561757}
     1758
     1759/**
     1760 * Helper function to get aria attributes allowed in KSES.
     1761 *
     1762 * @since 4.5.0
     1763 * @access private
     1764 *
     1765 * @return array The array of aria attributes with global attributes added.
     1766 */
     1767function _wp_get_aria_attributes() {
     1768        return array(
     1769                // Global attributes.
     1770                'aria-atomic'           => true,
     1771                'aria-busy'             => true,
     1772                'aria-controls'         => true,
     1773                'aria-describedby'      => true,
     1774                'aria-disabled'         => true,
     1775                'aria-dropeffect'       => true,
     1776                'aria-flowto'           => true,
     1777                'aria-grabbed'          => true,
     1778                'aria-haspopup'         => true,
     1779                'aria-hidden'           => true,
     1780                'aria-invalid'          => true,
     1781                'aria-label'            => true,
     1782                'aria-labelledby'       => true,
     1783                'aria-live'             => true,
     1784                'aria-owns'             => true,
     1785                'aria-relevant'         => true,
     1786
     1787                // Widget attributes.
     1788                'aria-autocomplete'     => true,
     1789                'aria-checked'          => true,
     1790                'aria-disabled'         => true,
     1791                'aria-expanded'         => true,
     1792                'aria-haspopup'         => true,
     1793                'aria-hidden'           => true,
     1794                'aria-invalid'          => true,
     1795                'aria-label'            => true,
     1796                'aria-level'            => true,
     1797                'aria-multiline'        => true,
     1798                'aria-multiselectable'  => true,
     1799                'aria-orientation'      => true,
     1800                'aria-pressed'          => true,
     1801                'aria-readonly'         => true,
     1802                'aria-required'         => true,
     1803                'aria-selected'         => true,
     1804                'aria-sort'             => true,
     1805                'aria-valuemax'         => true,
     1806                'aria-valuemin'         => true,
     1807                'aria-valuenow'         => true,
     1808                'aria-valuetext'        => true,
     1809
     1810                // Live region attributes.
     1811                'aria-atomic'           => true,
     1812                'aria-busy'             => true,
     1813                'aria-live'             => true,
     1814                'aria-relevant'         => true,
     1815
     1816                // Drag & Drop attributes
     1817                'aria-dropeffect'       => true,
     1818                'aria-grabbed'          => true,
     1819
     1820                // Relationship attributes
     1821                'aria-activedescendant' => true,
     1822                'aria-controls'         => true,
     1823                'aria-describedby'      => true,
     1824                'aria-flowto'           => true,
     1825                'aria-labelledby'       => true,
     1826                'aria-owns'             => true,
     1827                'aria-posinset'         => true,
     1828                'aria-setsize'          => true,
     1829        );
     1830}
  • tests/phpunit/tests/kses.php

    diff --git tests/phpunit/tests/kses.php tests/phpunit/tests/kses.php
    index c4c1e8e..cad59dc 100644
    class Tests_Kses extends WP_UnitTestCase { 
    5656        }
    5757
    5858        /**
     59         * @ticket 30421
     60         */
     61        function test_wp_kses_aria() {
     62                $aria_attributes = array(
     63                        'aria-atomic',
     64                        'aria-busy',
     65                        'aria-controls',
     66                        'aria-describedby',
     67                        'aria-disabled',
     68                        'aria-dropeffect',
     69                        'aria-flowto',
     70                        'aria-grabbed',
     71                        'aria-haspopup',
     72                        'aria-hidden',
     73                        'aria-invalid',
     74                        'aria-label',
     75                        'aria-labelledby',
     76                        'aria-live',
     77                        'aria-owns',
     78                        'aria-relevant',
     79                        'aria-autocomplete',
     80                        'aria-checked',
     81                        'aria-expanded',
     82                        'aria-level',
     83                        'aria-multiline',
     84                        'aria-multiselectable',
     85                        'aria-orientation',
     86                        'aria-pressed',
     87                        'aria-readonly',
     88                        'aria-required',
     89                        'aria-selected',
     90                        'aria-sort',
     91                        'aria-valuemax',
     92                        'aria-valuemin',
     93                        'aria-valuenow',
     94                        'aria-valuetext',
     95                        'aria-activedescendant',
     96                        'aria-posinset',
     97                        'aria-setsize',
     98                );
     99
     100                $attrs = array();
     101                foreach ( $aria_attributes as $attr ) {
     102                        $attrs[] = sprintf( '%s="%s"', $attr, 'value' );
     103                }
     104
     105                $el = sprintf( '<div %s></div>', implode( ' ', $attrs ) );
     106
     107                $this->assertEquals( $el, wp_kses_post( $el ) );
     108        }
     109
     110        /**
    59111         * @ticket 20210
    60112         */
    61113        function test_wp_filter_post_kses_abbr() {