Make WordPress Core

Changeset 42860


Ignore:
Timestamp:
03/20/2018 09:34:15 PM (7 years 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.
Fixes #43312.

Location:
trunk
Files:
2 edited

Legend:

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

    r42712 r42860  
    10481048
    10491049    // Are any attributes allowed at all for this element?
    1050     if ( ! isset( $allowed_html[ strtolower( $element ) ] ) || true === $allowed_html[ strtolower( $element ) ] || count( $allowed_html[ strtolower( $element ) ] ) == 0 ) {
     1050    $element_low = strtolower( $element );
     1051    if ( empty( $allowed_html[ $element_low ] ) || true === $allowed_html[ $element_low ] ) {
    10511052        return "<$element$xhtml_slash>";
    10521053    }
  • trunk/tests/phpunit/tests/kses.php

    r42343 r42860  
    723723        $this->assertEquals( "<{$element} title=\"foo\">", wp_kses_attr( $element, $attribute, array( 'foo' => array( 'title' => true ) ), array() ) );
    724724    }
     725
     726    /**
     727     * @ticket 43312
     728     */
     729    function test_wp_kses_attr_no_attributes_allowed_with_false() {
     730        $element   = 'foo';
     731        $attribute = 'title="foo" class="bar"';
     732
     733        $this->assertEquals( "<{$element}>", wp_kses_attr( $element, $attribute, array( 'foo' => false ), array() ) );
     734    }
    725735}
Note: See TracChangeset for help on using the changeset viewer.