Make WordPress Core


Ignore:
Timestamp:
01/28/2025 02:46:18 PM (20 months ago)
Author:
jorbin
Message:

HTML API: Ensure that full processor can seek to earlier bookmarks.

When the HTML Processor seeks to an earlier place, it returns the the beginning of the document and proceeds forward until it reaches the appropriate location. This requires resetting internal state so that the processor can correctly proceed from the beginning of the document.

The seeking reset logic was not adapted to account for the full processor (i.e. when created via WP_HTML_Processor::create_full_parser()). This change updates the seek logic to account for the full and fragment parsers as well as other state that has been introduced in the interim and should be reset.

Reviewed by westonruter, jorbin.
Merges [59391] to the 6.7 branch.

Props jonsurrell, dmsnell, westonruter, mi5t4n, bernhard-reiter.
Fixes #62290.

Location:
branches/6.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.7

  • branches/6.7/src/wp-includes/html-api/class-wp-html-open-elements.php

    r58992 r59721  
    521521                }
    522522
    523                 if ( 'context-node' === $item->bookmark_name ) {
    524                         $this->stack[] = $item;
    525                         return false;
    526                 }
    527 
    528523                $this->after_element_pop( $item );
    529524                return true;
     
    586581         */
    587582        public function remove_node( WP_HTML_Token $token ): bool {
    588                 if ( 'context-node' === $token->bookmark_name ) {
    589                         return false;
    590                 }
    591 
    592583                foreach ( $this->walk_up() as $position_from_end => $item ) {
    593584                        if ( $token->bookmark_name !== $item->bookmark_name ) {
Note: See TracChangeset for help on using the changeset viewer.