Make WordPress Core


Ignore:
Timestamp:
08/30/2023 03:37:33 PM (13 months ago)
Author:
Bernhard Reiter
Message:

HTML API: Stop processing HTML when encountering unsupported markup.

It was a design goal of the HTML Processor to abort processing its input document when encountering unsupported markup. Unfortunately there was no test for this and so-far, the HTML Processor has paused, but continued processing in these situations.

In this patch a new test ensures that the HTML Processor stops and refuses to move forward after encountering any unsupported markup. It also ensures that it doesn't report any current tag names since unsupported markup could imply that the read tag name is different than the parsed tag name.

Props dmsnell.
Fixes #59167.

File:
1 edited

Legend:

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

    r56380 r56493  
    433433     */
    434434    public function step( $node_to_process = self::PROCESS_NEXT_NODE ) {
     435        // Refuse to proceed if there was a previous error.
     436        if ( null !== $this->last_error ) {
     437            return false;
     438        }
     439
    435440        if ( self::PROCESS_NEXT_NODE === $node_to_process ) {
    436441            $top_node = $this->state->stack_of_open_elements->current_node();
     
    745750     */
    746751    public function get_tag() {
     752        if ( null !== $this->last_error ) {
     753            return null;
     754        }
     755
    747756        $tag_name = parent::get_tag();
    748757
Note: See TracChangeset for help on using the changeset viewer.