diff --git a/wp-includes/html-api/class-wp-html-processor.php b/wp-includes/html-api/class-wp-html-processor.php index 7b156d8a60..8d2a476769 100644 --- a/wp-includes/html-api/class-wp-html-processor.php +++ b/wp-includes/html-api/class-wp-html-processor.php @@ -303,7 +303,9 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor { } while ( $context_processor->next_tag() ) { - $context_processor->set_bookmark( 'final_node' ); + if ( ! $context_processor->is_virtual() ) { + $context_processor->set_bookmark( 'final_node' ); + } } if ( @@ -5673,12 +5675,25 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor { * reaching for it, as inappropriate use could lead to broken * HTML structure or unwanted processing overhead. * + * Bookmarks cannot be set on tokens that do no appear in the original + * HTML text. For example, the HTML `
` stops at tags `TABLE`, + * `TBODY`, `TR`, and `TD`. The `TBODY` and `TR` tags do not appear in + * the original HTML and cannot be used as bookmarks. + * * @since 6.4.0 * * @param string $bookmark_name Identifies this particular bookmark. * @return bool Whether the bookmark was successfully created. */ public function set_bookmark( $bookmark_name ): bool { + if ( $this->is_virtual() ) { + _doing_it_wrong( + __METHOD__, + __( 'Cannot set bookmarks on tokens that do no appear in the original HTML text.' ), + '6.8.0' + ); + return false; + } return parent::set_bookmark( "_{$bookmark_name}" ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index a040087f3b..c7e61f20a4 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-alpha-59501'; +$wp_version = '6.8-alpha-59502'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.