From c9ddecbf094086d91dd833795151b4e2fd510924 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 17 Oct 2023 10:37:35 +0000 Subject: [PATCH] HTML API: Scan to end of tag when getting updated HTML output. When applying updates to HTML, one step was left out in [56941] which updated the position of the end of the current tag. This made it possible to create bookmarks with null or earlier end positions than their start position. This in turn broke the Directive Processor in Gutenberg during the backport of changes from Core into Gutenberg. In this commit, after applying updates, the HTML document is now scanned fully to the end of the current tag, updating the internal pointer to its end, so that nothing else will be broken or misaligned. Follow-up to [56941]. Props dmsnell. Fixes #59643. git-svn-id: https://develop.svn.wordpress.org/trunk@56953 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/html-api/class-wp-html-tag-processor.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wp-includes/html-api/class-wp-html-tag-processor.php b/src/wp-includes/html-api/class-wp-html-tag-processor.php index 445de9ee29..1fe0029319 100644 --- a/src/wp-includes/html-api/class-wp-html-tag-processor.php +++ b/src/wp-includes/html-api/class-wp-html-tag-processor.php @@ -2324,6 +2324,10 @@ class WP_HTML_Tag_Processor { continue; } + $tag_ends_at = strpos( $this->html, '>', $this->bytes_already_parsed ); + $this->tag_ends_at = $tag_ends_at; + $this->bytes_already_parsed = $tag_ends_at; + return $this->html; }