WordPress.org

Make WordPress Core

Changeset 42861


Ignore:
Timestamp:
03/20/2018 09:36:04 PM (21 months ago)
Author:
SergeyBiryukov
Message:

Formatting: Avoid a PHP 7.2 warning in wp_kses_attr() when one of $allowedtags elements is an uncountable value.

Props andrei0x309, soulseekah, SergeyBiryukov.
Merges [42860] to the 4.9 branch.
Fixes #43312.

Location:
branches/4.9
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-includes/kses.php

    r40950 r42861  
    828828
    829829    // Are any attributes allowed at all for this element?
    830     if ( ! isset( $allowed_html[ strtolower( $element ) ] ) || true === $allowed_html[ strtolower( $element ) ] || count( $allowed_html[ strtolower( $element ) ] ) == 0 ) {
     830    $element_low = strtolower( $element );
     831    if ( empty( $allowed_html[ $element_low ] ) || true === $allowed_html[ $element_low ] ) {
    831832        return "<$element$xhtml_slash>";
    832833    }
  • branches/4.9/tests/phpunit/tests/kses.php

    r40637 r42861  
    709709        $this->assertEquals( "<{$element} title=\"foo\">", wp_kses_attr( $element, $attribute, array( 'foo' => array( 'title' => true ) ), array() ) );
    710710    }
     711
     712    /**
     713     * @ticket 43312
     714     */
     715    function test_wp_kses_attr_no_attributes_allowed_with_false() {
     716        $element   = 'foo';
     717        $attribute = 'title="foo" class="bar"';
     718
     719        $this->assertEquals( "<{$element}>", wp_kses_attr( $element, $attribute, array( 'foo' => false ), array() ) );
     720    }
    711721}
Note: See TracChangeset for help on using the changeset viewer.