Make WordPress Core


Ignore:
Timestamp:
06/01/2026 10:38:30 AM (4 months ago)
Author:
dmsnell
Message:

HTML API: Fixes for issues discovered while fuzzing.

Fuzz-testing was performed against the HTML API for finding edge cases
that might be broken in the existing parsing code. A few issues were
discovered with HTML normalization and warnings from out-of-bounds
string reads.

This patch contains new tests catching regressions on these behaviors
and adds fixes for the discovered issues.

Patch proposed by Codex and revised by dmsnell.

Developed in: https://github.com/WordPress/wordpress-develop/pull/11982
Discussed in: https://core.trac.wordpress.org/ticket/65372

Fixes #65372.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/html-api/class-wp-html-tag-processor.php

    r62359 r62439  
    14251425
    14261426                        // Fail if there is no possible tag closer.
    1427                         if ( false === $at || ( $at + $tag_length ) >= $doc_length ) {
     1427                        if ( false === $at || ( $at + 2 + $tag_length ) >= $doc_length ) {
    14281428                                return false;
    14291429                        }
     
    18161816                                        // Abruptly-closed empty comments are a sequence of dashes followed by `>`.
    18171817                                        $span_of_dashes = strspn( $html, '-', $closer_at );
     1818                                        if ( $doc_length <= $span_of_dashes + $closer_at ) {
     1819                                                $this->parser_state = self::STATE_INCOMPLETE_INPUT;
     1820
     1821                                                return false;
     1822                                        }
     1823
    18181824                                        if ( '>' === $html[ $closer_at + $span_of_dashes ] ) {
    18191825                                                /*
Note: See TracChangeset for help on using the changeset viewer.