diff --git a/src/wp-includes/html-api/class-wp-html-processor.php b/src/wp-includes/html-api/class-wp-html-processor.php index 14cb296d43..bba7ed5f48 100644 --- a/src/wp-includes/html-api/class-wp-html-processor.php +++ b/src/wp-includes/html-api/class-wp-html-processor.php @@ -557,6 +557,10 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor { return false; } + if ( isset( $query['tag_name'] ) ) { + $query['tag_name'] = strtoupper( $query['tag_name'] ); + } + $needs_class = ( isset( $query['class_name'] ) && is_string( $query['class_name'] ) ) ? $query['class_name'] : null; diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessor.php b/tests/phpunit/tests/html-api/wpHtmlProcessor.php index 792f297142..1ece27c9db 100644 --- a/tests/phpunit/tests/html-api/wpHtmlProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlProcessor.php @@ -882,4 +882,19 @@ class Tests_HtmlApi_WpHtmlProcessor extends WP_UnitTestCase { $this->assertSame( 'FORM', $processor->get_tag() ); $this->assertTrue( $processor->is_tag_closer() ); } + + /** + * Ensure that lowercased tag_name query matches tags case-insensitively. + * + * @group 62427 + */ + public function test_next_tag_lowercase_tag_name() { + // The upper case