Make WordPress Core

Changeset 58858


Ignore:
Timestamp:
08/06/2024 08:41:58 PM (18 months ago)
Author:
dmsnell
Message:

HTML API: Truncated funky comments should cause the Tag Processor to pause.

A state change was missing in the Tag Processor when the input is too short to
find a comment closer after an opened funky comment. This patch fixes a issue
where </# does not correctly report incomplete input, but </# does.

Developed in https://github.com/wordpress/wordpress-develop/pull/7146
Discussed in https://core.trac.wordpress.org/ticket/61831

Props: jonsurrell.
Fixes #61831.

Location:
trunk
Files:
2 edited

Legend:

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

    r58845 r58858  
    19101910                // No chance of finding a closer.
    19111911                if ( $at + 3 > $doc_length ) {
     1912                    $this->parser_state = self::STATE_INCOMPLETE_INPUT;
     1913
    19121914                    return false;
    19131915                }
  • trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php

    r58845 r58858  
    29042904        $this->assertTrue( $processor->paused_at_incomplete_token() );
    29052905    }
     2906
     2907    /**
     2908     * Test a bugfix where the input ends abruptly with a funky comment started.
     2909     *
     2910     * @ticket 61831
     2911     */
     2912    public function test_unclosed_funky_comment_input_too_short() {
     2913        $processor = new WP_HTML_Tag_Processor( '</#' );
     2914        $this->assertFalse( $processor->next_tag() );
     2915        $this->assertTrue( $processor->paused_at_incomplete_token() );
     2916    }
    29062917}
Note: See TracChangeset for help on using the changeset viewer.