diff --git a/src/wp-includes/kses.php b/src/wp-includes/kses.php index 93fc9dd00b..265fb748ac 100644 --- a/src/wp-includes/kses.php +++ b/src/wp-includes/kses.php @@ -1047,7 +1047,8 @@ function wp_kses_attr( $element, $attr, $allowed_html, $allowed_protocols ) { } // Are any attributes allowed at all for this element? - if ( ! isset( $allowed_html[ strtolower( $element ) ] ) || true === $allowed_html[ strtolower( $element ) ] || count( $allowed_html[ strtolower( $element ) ] ) == 0 ) { + $element_low = strtolower( $element ); + if ( empty( $allowed_html[ $element_low ] ) || true === $allowed_html[ $element_low ] ) { return "<$element$xhtml_slash>"; } diff --git a/tests/phpunit/tests/kses.php b/tests/phpunit/tests/kses.php index 1a307972cc..8be7f9379c 100644 --- a/tests/phpunit/tests/kses.php +++ b/tests/phpunit/tests/kses.php @@ -722,4 +722,14 @@ EOF; $this->assertEquals( "<{$element} title=\"foo\">", wp_kses_attr( $element, $attribute, array( 'foo' => array( 'title' => true ) ), array() ) ); } + + /** + * @ticket 43312 + */ + function test_wp_kses_attr_no_attributes_allowed_with_false() { + $element = 'foo'; + $attribute = 'title="foo" class="bar"'; + + $this->assertEquals( "<{$element}>", wp_kses_attr( $element, $attribute, array( 'foo' => false ), array() ) ); + } }