HTML API: Fix finding RCData and Script tag closers.

Fixes finding the following tag closers `</script>`, `</textarea>`, and `</title>` in `WP_HTML_Tag_Processor`.

Follow-up to [55407], [55203].

Props zieladam, dmsnell, hellofromTonya.
Fixes #57852.
See #57575.

git-svn-id: https://develop.svn.wordpress.org/trunk@55469 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Tonya Mork
2023-03-06 18:53:38 +00:00
parent 65c7df0344
commit 455b1e857e
2 changed files with 47 additions and 5 deletions
@@ -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;
}
}