diff --git a/lib/compat/wordpress-6.4/html-api/class-wp-html-processor.php b/lib/compat/wordpress-6.4/html-api/class-wp-html-processor.php index b348a982a4686..d7ec401787313 100644 --- a/lib/compat/wordpress-6.4/html-api/class-wp-html-processor.php +++ b/lib/compat/wordpress-6.4/html-api/class-wp-html-processor.php @@ -436,6 +436,11 @@ public function next_tag( $query = null ) { * @return bool Whether a tag was matched. */ public function step( $node_to_process = self::PROCESS_NEXT_NODE ) { + // Refuse to proceed if there was a previous error. + if ( null !== $this->last_error ) { + return false; + } + if ( self::PROCESS_NEXT_NODE === $node_to_process ) { $top_node = $this->state->stack_of_open_elements->current_node(); if ( $top_node && self::is_void( $top_node->node_name ) ) { @@ -748,6 +753,10 @@ private function bookmark_tag() { * @return string|null Name of currently matched tag in input HTML, or `null` if none found. */ public function get_tag() { + if ( null !== $this->last_error ) { + return null; + } + $tag_name = parent::get_tag(); switch ( $tag_name ) {