Make WordPress Core


Ignore:
Timestamp:
01/19/2024 09:40:01 PM (11 months ago)
Author:
dmsnell
Message:

HTML API: Add support for BR, EMBED, & other tags.

Adds support for the following HTML elements to the HTML Processor:

  • AREA, BR, EMBED, KEYGEN, WBR
  • Only the opening BR tag is supported, as the invalid closer </br> involves more complicated rules, to be implemented later.

Previously, these elements were not supported and the HTML Processor
would bail when encountering them. With this patch it will proceed to
parse an HTML document when encountering those tags as long as other
normal conditions don't cause it to bail (such as complicated format
reconstruction rules).

Props jonsurrell, dmsnell
Fixes #60283

File:
1 edited

Legend:

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

    r57314 r57316  
    103103 *  - Custom elements: All custom elements are supported. :)
    104104 *  - Form elements: BUTTON, DATALIST, FIELDSET, LABEL, LEGEND, METER, PROGRESS, SEARCH.
    105  *  - Formatting elements: B, BIG, CODE, EM, FONT, I, SMALL, STRIKE, STRONG, TT, U.
     105 *  - Formatting elements: B, BIG, CODE, EM, FONT, I, SMALL, STRIKE, STRONG, TT, U, WBR.
    106106 *  - Heading elements: H1, H2, H3, H4, H5, H6, HGROUP.
    107107 *  - Links: A.
    108108 *  - Lists: DD, DL, DT, LI, OL, LI.
    109  *  - Media elements: AUDIO, CANVAS, FIGCAPTION, FIGURE, IMG, MAP, PICTURE, VIDEO.
    110  *  - Paragraph: P.
    111  *  - Phrasing elements: ABBR, BDI, BDO, CITE, DATA, DEL, DFN, INS, MARK, OUTPUT, Q, SAMP, SUB, SUP, TIME, VAR.
     109 *  - Media elements: AUDIO, CANVAS, EMBED, FIGCAPTION, FIGURE, IMG, MAP, PICTURE, VIDEO.
     110 *  - Paragraph: BR, P.
     111 *  - Phrasing elements: AREA, ABBR, BDI, BDO, CITE, DATA, DEL, DFN, INS, MARK, OUTPUT, Q, SAMP, SUB, SUP, TIME, VAR.
    112112 *  - Sectioning elements: ARTICLE, ASIDE, HR, NAV, SECTION.
    113113 *  - Templating elements: SLOT.
    114114 *  - Text decoration: RUBY.
    115  *  - Deprecated elements: ACRONYM, BLINK, CENTER, DIR, ISINDEX, MULTICOL, NEXTID, SPACER.
     115 *  - Deprecated elements: ACRONYM, BLINK, CENTER, DIR, ISINDEX, KEYGEN, MULTICOL, NEXTID, SPACER.
    116116 *
    117117 * ### Supported markup
     
    936936
    937937            /*
     938             * > An end tag whose tag name is "br"
     939             * >   Parse error. Drop the attributes from the token, and act as described in the next
     940             * >   entry; i.e. act as if this was a "br" start tag token with no attributes, rather
     941             * >   than the end tag token that it actually is.
     942             */
     943            case '-BR':
     944                $this->last_error = self::ERROR_UNSUPPORTED;
     945                throw new WP_HTML_Unsupported_Exception( 'Closing BR tags require unimplemented special handling.' );
     946
     947            /*
    938948             * > A start tag whose tag name is one of: "area", "br", "embed", "img", "keygen", "wbr"
    939949             */
     950            case '+AREA':
     951            case '+BR':
     952            case '+EMBED':
    940953            case '+IMG':
     954            case '+KEYGEN':
     955            case '+WBR':
    941956                $this->reconstruct_active_formatting_elements();
    942957                $this->insert_html_element( $this->state->current_token );
     958                $this->state->frameset_ok = false;
    943959                return true;
    944960
     
    978994            case 'BGSOUND':
    979995            case 'BODY':
    980             case 'BR':
    981996            case 'CAPTION':
    982997            case 'COL':
     
    984999            case 'DD':
    9851000            case 'DT':
    986             case 'EMBED':
    9871001            case 'FORM':
    9881002            case 'FRAME':
     
    9921006            case 'IFRAME':
    9931007            case 'INPUT':
    994             case 'KEYGEN':
    9951008            case 'LI':
    9961009            case 'LINK':
     
    10321045            case 'TRACK':
    10331046            case 'UL':
    1034             case 'WBR':
    10351047            case 'XMP':
    10361048                $this->last_error = self::ERROR_UNSUPPORTED;
     
    16931705            'INPUT' === $tag_name ||
    16941706            'LINK' === $tag_name ||
     1707            'KEYGEN' === $tag_name || // Obsolete but still treated as void.
    16951708            'META' === $tag_name ||
    16961709            'SOURCE' === $tag_name ||
Note: See TracChangeset for help on using the changeset viewer.