Make WordPress Core

Changeset 40637


Ignore:
Timestamp:
05/11/2017 07:22:17 PM (10 years ago)
Author:
ocean90
Message:

KSES: Support 'tag' => true as a shorthand for 'tag' => array() in wp_kses_attr().

Automatic_Upgrader_Skin::feedback() had always assumed that this is already the case, now it is.

See #20017.
Fixes #40680.

Location:
trunk
Files:
2 edited

Legend:

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

    r39638 r40637  
    829829
    830830        // Are any attributes allowed at all for this element?
    831         if ( ! isset($allowed_html[strtolower($element)]) || count($allowed_html[strtolower($element)]) == 0 )
     831        if ( ! isset( $allowed_html[ strtolower( $element ) ] ) || true === $allowed_html[ strtolower( $element ) ] || count( $allowed_html[ strtolower( $element ) ] ) == 0 ) {
    832832                return "<$element$xhtml_slash>";
     833        }
    833834
    834835        // Split it
  • trunk/tests/phpunit/tests/kses.php

    r38785 r40637  
    679679                $this->assertEquals( $input, wp_kses( $input, $allowedposttags ) );
    680680        }
     681
     682        /**
     683         * @ticket 40680
     684         */
     685        function test_wp_kses_attr_no_attributes_allowed_with_empty_array() {
     686                $element = 'foo';
     687                $attribute = 'title="foo" class="bar"';
     688
     689                $this->assertEquals( "<{$element}>", wp_kses_attr( $element, $attribute, array( 'foo' => array() ), array() ) );
     690        }
     691
     692        /**
     693         * @ticket 40680
     694         */
     695        function test_wp_kses_attr_no_attributes_allowed_with_true() {
     696                $element = 'foo';
     697                $attribute = 'title="foo" class="bar"';
     698
     699                $this->assertEquals( "<{$element}>", wp_kses_attr( $element, $attribute, array( 'foo' => true ), array() ) );
     700        }
     701
     702        /**
     703         * @ticket 40680
     704         */
     705        function test_wp_kses_attr_single_attribute_is_allowed() {
     706                $element = 'foo';
     707                $attribute = 'title="foo" class="bar"';
     708
     709                $this->assertEquals( "<{$element} title=\"foo\">", wp_kses_attr( $element, $attribute, array( 'foo' => array( 'title' => true ) ), array() ) );
     710        }
    681711}
Note: See TracChangeset for help on using the changeset viewer.