diff --git a/wp-includes/html-api/class-wp-html-processor.php b/wp-includes/html-api/class-wp-html-processor.php
index 6e1723494c..b5a20dbd82 100644
--- a/wp-includes/html-api/class-wp-html-processor.php
+++ b/wp-includes/html-api/class-wp-html-processor.php
@@ -432,6 +432,11 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
* @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 ) ) {
@@ -744,6 +749,10 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
* @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 ) {
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 0aac5f5e9b..460549500d 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '6.4-alpha-56492';
+$wp_version = '6.4-alpha-56493';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.