From f200230d18a6f3d1d4883f8d2927d04122f92bb9 Mon Sep 17 00:00:00 2001 From: dmsnell Date: Thu, 8 Aug 2024 04:26:13 +0000 Subject: [PATCH] HTML API: Ensure that `get_modifiable_text()` reads enqueued updates. When `set_modifiable_text()` was added to the Tag Processor, it was considered that the same information could be queried after setting its value and before proceeding to the next token, but unfortunately overlooked that if the starting modifiable text length was zero, then the read in `get_modifiable_text()` would ignore enqueued updates. In this patch, `get_modifiable_text()` will read any enqueued values before reading from the input HTML document to ensure consistency. Follow-up to [58829]. Props dmsnell, jonsurrell, ramonopoly. Fixes #61617. Built from https://develop.svn.wordpress.org/trunk@58866 git-svn-id: http://core.svn.wordpress.org/trunk@58262 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/html-api/class-wp-html-tag-processor.php | 8 +++++--- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/wp-includes/html-api/class-wp-html-tag-processor.php b/wp-includes/html-api/class-wp-html-tag-processor.php index fcf418e856..0ff2cdc4dd 100644 --- a/wp-includes/html-api/class-wp-html-tag-processor.php +++ b/wp-includes/html-api/class-wp-html-tag-processor.php @@ -614,7 +614,7 @@ class WP_HTML_Tag_Processor { * * @since 6.5.0 * - * @var string + * @var int */ private $text_length; @@ -2894,11 +2894,13 @@ class WP_HTML_Tag_Processor { * @return string */ public function get_modifiable_text(): string { - if ( null === $this->text_starts_at || 0 === $this->text_length ) { + $has_enqueued_update = isset( $this->lexical_updates['modifiable text'] ); + + if ( ! $has_enqueued_update && ( null === $this->text_starts_at || 0 === $this->text_length ) ) { return ''; } - $text = isset( $this->lexical_updates['modifiable text'] ) + $text = $has_enqueued_update ? $this->lexical_updates['modifiable text']->text : substr( $this->html, $this->text_starts_at, $this->text_length ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 62c0b10642..f4d8950bd7 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.7-alpha-58865'; +$wp_version = '6.7-alpha-58866'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.