Skip to content

Commit 2a1e1be

Browse files
committed
Move pointer increment into loop condition to avoid infinite loops
This is just a safety precaution to mitigate an accidental removal of the pointer increment. No actual problems motivated this change.
1 parent 46af172 commit 2a1e1be

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,8 @@ private function parse_next_tag() {
10561056
*
10571057
* See https://html.spec.whatwg.org/#parse-error-incorrectly-closed-comment
10581058
*/
1059-
while ( $closer_at < strlen( $html ) ) {
1059+
$closer_at--; // Pre-increment inside condition avoids risk of infinite looping.
1060+
while ( ++$closer_at < strlen( $html ) ) {
10601061
$closer_at = strpos( $html, '--', $closer_at );
10611062
if ( false === $closer_at ) {
10621063
return false;
@@ -1071,8 +1072,6 @@ private function parse_next_tag() {
10711072
$at = $closer_at + 4;
10721073
continue 2;
10731074
}
1074-
1075-
$closer_at = $closer_at + 1;
10761075
}
10771076
}
10781077

0 commit comments

Comments
 (0)