From bccb3e46e13e54e02fe9654eae0c21de9e736846 Mon Sep 17 00:00:00 2001 From: dmsnell Date: Sat, 6 Jul 2024 10:20:15 +0000 Subject: [PATCH] HTML API: Respect `tag_name` query arg in `HTML_Processor::next_tag()` Previously the HTML Processor was ignoring the `tag_name` argument in the `next_tag()` query if it existed. This was wrong adn would lead to calling code finding the very next tag, regardless of tag name, instead of the requested taag. This patch adds the tag name detection code into `next_tag()` to fix the bug and ensure that `next_tag()` always returns only when finding a tag of the given name. Developed in https://github.com/WordPress/wordpress-develop/pull/6980 Discussed in https://core.trac.wordpress.org/ticket/61581 Follow-up to [56274]. Fixes #61581. Built from https://develop.svn.wordpress.org/trunk@58681 git-svn-id: http://core.svn.wordpress.org/trunk@58083 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/html-api/class-wp-html-processor.php | 4 ++++ wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wp-includes/html-api/class-wp-html-processor.php b/wp-includes/html-api/class-wp-html-processor.php index cbf1dc6336..588d2fbe7d 100644 --- a/wp-includes/html-api/class-wp-html-processor.php +++ b/wp-includes/html-api/class-wp-html-processor.php @@ -466,6 +466,10 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor { continue; } + if ( isset( $query['tag_name'] ) && $query['tag_name'] !== $this->get_token_name() ) { + continue; + } + if ( isset( $needs_class ) && ! $this->has_class( $needs_class ) ) { continue; } diff --git a/wp-includes/version.php b/wp-includes/version.php index fed502578b..9c2df13cf3 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.7-alpha-58680'; +$wp_version = '6.7-alpha-58681'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.