Skip to content

Commit

Permalink
Fix bug found from HTML5Tests for incomplete SCRIPT tag closer
Browse files Browse the repository at this point in the history
Co-authored-by: Jon Surrell <sirreal@users.noreply.github.com>
  • Loading branch information
dmsnell and sirreal committed Dec 20, 2023
1 parent 9e7167a commit 8488317
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/wp-includes/html-api/class-wp-html-tag-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,12 @@ private function skip_script_data() {
continue;
}

if ( $this->bytes_already_parsed >= $doc_length ) {
$this->parser_state = self::STATE_INCOMPLETE;

return false;
}

if ( '>' === $html[ $this->bytes_already_parsed ] ) {
$this->bytes_already_parsed = $closer_potentially_starts_at;
return true;
Expand Down Expand Up @@ -1362,7 +1368,7 @@ private function parse_next_tag() {
* https://html.spec.whatwg.org/multipage/parsing.html#tag-open-state
*/
if (
strlen( $html ) > $at + 3 &&
$doc_length > $at + 3 &&
'-' === $html[ $at + 2 ] &&
'-' === $html[ $at + 3 ]
) {
Expand Down

0 comments on commit 8488317

Please sign in to comment.