Skip to content

Commit 1270194

Browse files
committed
Fix bug found from HTML5Tests for incomplete SCRIPT tag closer
1 parent 9e7167a commit 1270194

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/wp-includes/html-api/class-wp-html-tag-processor.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,12 @@ private function skip_script_data() {
12671267
continue;
12681268
}
12691269

1270+
if ( $this->bytes_already_parsed >= $doc_length ) {
1271+
$this->parser_state = self::STATE_INCOMPLETE;
1272+
1273+
return false;
1274+
}
1275+
12701276
if ( '>' === $html[ $this->bytes_already_parsed ] ) {
12711277
$this->bytes_already_parsed = $closer_potentially_starts_at;
12721278
return true;
@@ -1362,7 +1368,7 @@ private function parse_next_tag() {
13621368
* https://html.spec.whatwg.org/multipage/parsing.html#tag-open-state
13631369
*/
13641370
if (
1365-
strlen( $html ) > $at + 3 &&
1371+
$doc_length > $at + 3 &&
13661372
'-' === $html[ $at + 2 ] &&
13671373
'-' === $html[ $at + 3 ]
13681374
) {

0 commit comments

Comments
 (0)