diff --git a/wp-includes/html-api/class-wp-html-processor.php b/wp-includes/html-api/class-wp-html-processor.php
index 8a63353787..f9a449c3c6 100644
--- a/wp-includes/html-api/class-wp-html-processor.php
+++ b/wp-includes/html-api/class-wp-html-processor.php
@@ -1042,8 +1042,17 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
$token_name = $this->get_token_name();
if ( self::REPROCESS_CURRENT_NODE !== $node_to_process ) {
+ try {
+ $bookmark_name = $this->bookmark_token();
+ } catch ( Exception $e ) {
+ if ( self::ERROR_EXCEEDED_MAX_BOOKMARKS === $this->last_error ) {
+ return false;
+ }
+ throw $e;
+ }
+
$this->state->current_token = new WP_HTML_Token(
- $this->bookmark_token(),
+ $bookmark_name,
$token_name,
$this->has_self_closing_flag(),
$this->release_internal_bookmark_on_destruct
@@ -1153,6 +1162,12 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
* otherwise might involve messier calling and return conventions.
*/
return false;
+ } catch ( Exception $e ) {
+ if ( self::ERROR_EXCEEDED_MAX_BOOKMARKS === $this->last_error ) {
+ return false;
+ }
+ // Rethrow any other exceptions for higher-level handling.
+ throw $e;
}
}
@@ -6315,6 +6330,8 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
*
* @since 6.7.0
*
+ * @throws Exception When unable to allocate a bookmark for the next token in the input HTML document.
+ *
* @param string $token_name Name of token to create and insert into the stack of open elements.
* @param string|null $bookmark_name Optional. Name to give bookmark for created virtual node.
* Defaults to auto-creating a bookmark name.
diff --git a/wp-includes/version.php b/wp-includes/version.php
index ffb04ca788..a315c53c95 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.0-beta2-61754';
+$wp_version = '7.0-beta2-61755';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.