Skip to content

Commit

Permalink
HTML API: Scan to end of tag when getting updated HTML output.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
SergeyBiryukov committed Oct 17, 2023
1 parent 112f7da commit c9ddecb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/wp-includes/html-api/class-wp-html-tag-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2324,6 +2324,10 @@ public function get_updated_html() {
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;
}

Expand Down

0 comments on commit c9ddecb

Please sign in to comment.