From 39308664bf5420716e9f3e130b05b8d6f67cb20f Mon Sep 17 00:00:00 2001 From: hellofromTonya Date: Mon, 6 Mar 2023 18:55:21 +0000 Subject: [PATCH] HTML API: Fix finding RCData and Script tag closers. Fixes finding the following tag closers ``, ``, and `` in `WP_HTML_Tag_Processor`. Follow-up to [55407], [55203]. Props zieladam, dmsnell, hellofromTonya. Fixes #57852. See #57575. Built from https://develop.svn.wordpress.org/trunk@55469 git-svn-id: http://core.svn.wordpress.org/trunk@55002 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/html-api/class-wp-html-tag-processor.php | 12 +++++++----- wp-includes/version.php | 2 +- 2 files changed, 8 insertions(+), 6 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 044d1f0c36..0b3dab1ad2 100644 --- a/wp-includes/html-api/class-wp-html-tag-processor.php +++ b/wp-includes/html-api/class-wp-html-tag-processor.php @@ -775,7 +775,8 @@ class WP_HTML_Tag_Processor { return false; } - $at += 2; + $closer_potentially_starts_at = $at; + $at += 2; /* * Find a case-insensitive match to the tag name. @@ -818,7 +819,7 @@ class WP_HTML_Tag_Processor { } if ( '>' === $html[ $at ] || '/' === $html[ $at ] ) { - ++$this->bytes_already_parsed; + $this->bytes_already_parsed = $closer_potentially_starts_at; return true; } } @@ -887,7 +888,8 @@ class WP_HTML_Tag_Processor { } if ( '/' === $html[ $at ] ) { - $is_closing = true; + $closer_potentially_starts_at = $at - 1; + $is_closing = true; ++$at; } else { $is_closing = false; @@ -938,7 +940,7 @@ class WP_HTML_Tag_Processor { } if ( $is_closing ) { - $this->bytes_already_parsed = $at; + $this->bytes_already_parsed = $closer_potentially_starts_at; if ( $this->bytes_already_parsed >= $doc_length ) { return false; } @@ -948,7 +950,7 @@ class WP_HTML_Tag_Processor { } if ( '>' === $html[ $this->bytes_already_parsed ] ) { - ++$this->bytes_already_parsed; + $this->bytes_already_parsed = $closer_potentially_starts_at; return true; } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 8bc6031327..1dc96f0435 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-beta4-55468'; +$wp_version = '6.2-beta4-55469'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.