Make WordPress Core

Changeset 59500


Ignore:
Timestamp:
12/09/2024 12:42:42 PM (2 months ago)
Author:
gziolo
Message:

HTML API: Step past closing HTML, BODY tags

The HTML specification does not close HTML or BODY tags (pop them off the stack of open elements) when their tag closers are encountered. The HTML processor correctly handled this behavior, however it incorrectly "paused" by returning true from the step functions.

Props jonsurrell, dmsnell, gziolo.
Fixes #62583.

File:
1 edited

Legend:

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

    r59469 r59500  
    23192319
    23202320                $this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_AFTER_BODY;
    2321                 return true;
     2321                /*
     2322                 * The BODY element is not removed from the stack of open elements.
     2323                 * Only internal state has changed, this does not qualify as a "step"
     2324                 * in terms of advancing through the document to another token.
     2325                 * Nothing has been pushed or popped.
     2326                 * Proceed to parse the next item.
     2327                 */
     2328                return $this->step();
    23222329
    23232330            /*
     
    43924399
    43934400                $this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_AFTER_AFTER_BODY;
    4394                 return true;
     4401                /*
     4402                 * The HTML element is not removed from the stack of open elements.
     4403                 * Only internal state has changed, this does not qualify as a "step"
     4404                 * in terms of advancing through the document to another token.
     4405                 * Nothing has been pushed or popped.
     4406                 * Proceed to parse the next item.
     4407                 */
     4408                return $this->step();
    43954409        }
    43964410
     
    45874601            case '-HTML':
    45884602                $this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_AFTER_AFTER_FRAMESET;
    4589                 return true;
     4603                /*
     4604                 * The HTML element is not removed from the stack of open elements.
     4605                 * Only internal state has changed, this does not qualify as a "step"
     4606                 * in terms of advancing through the document to another token.
     4607                 * Nothing has been pushed or popped.
     4608                 * Proceed to parse the next item.
     4609                 */
     4610                return $this->step();
    45904611
    45914612            /*
Note: See TracChangeset for help on using the changeset viewer.