Make WordPress Core


Ignore:
Timestamp:
01/08/2024 02:03:40 PM (11 months ago)
Author:
Bernhard Reiter
Message:

HTML API: Add explicit handling or failure for all tags.

The HTML API HTML processor does not yet support all tags. Many tags (e.g. list elements) have some complicated rules in the "in body" insertion mode.

Implementing these special rules is blocking the implementation for a catch-all rule for "any other tag" because we need to prevent special rules from being handled by the catch-all.

Any other start tag
Reconstruct the active formatting elements, if any.

Insert an HTML element for the token.


This change ensures the HTML Processor fails when handling special tags. This is the same as existing behavior, but will allow us to implement the catch-all "any other tag" handling without unintentionally handling special elements.

Additionally, we add tests that assert the special elements are unhandled. As these tags are implemented, this should help to ensure they're removed from the unsupported tag list.

Props jonsurrell, dmsnell.
Fixes #60092.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/html-api/wpHtmlSupportRequiredOpenElements.php

    r56790 r57248  
    7373        $this->ensure_support_is_added_everywhere( 'TEMPLATE' );
    7474
    75         // MathML Elements
    76         $this->ensure_support_is_added_everywhere( 'MI' );
    77         $this->ensure_support_is_added_everywhere( 'MO' );
    78         $this->ensure_support_is_added_everywhere( 'MN' );
    79         $this->ensure_support_is_added_everywhere( 'MS' );
    80         $this->ensure_support_is_added_everywhere( 'MTEXT' );
    81         $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' );
    82 
    83         /*
    84          * SVG elements: note that TITLE is both an HTML element and an SVG element
    85          * so care must be taken when adding support for either one.
    86          */
    87         $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' );
    88         $this->ensure_support_is_added_everywhere( 'DESC' );
    89         $this->ensure_support_is_added_everywhere( 'TITLE' );
     75        // MathML Elements: MI, MO, MN, MS, MTEXT, ANNOTATION-XML.
     76        $this->ensure_support_is_added_everywhere( 'MATH' );
     77
     78        /*
     79         * SVG elements: note that TITLE is both an HTML element and an SVG element
     80         * so care must be taken when adding support for either one.
     81         *
     82         * FOREIGNOBJECT, DESC, TITLE.
     83         */
     84        $this->ensure_support_is_added_everywhere( 'SVG' );
    9085    }
    9186
     
    116111        $this->ensure_support_is_added_everywhere( 'TEMPLATE' );
    117112
    118         // MathML Elements
    119         $this->ensure_support_is_added_everywhere( 'MI' );
    120         $this->ensure_support_is_added_everywhere( 'MO' );
    121         $this->ensure_support_is_added_everywhere( 'MN' );
    122         $this->ensure_support_is_added_everywhere( 'MS' );
    123         $this->ensure_support_is_added_everywhere( 'MTEXT' );
    124         $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' );
    125 
    126         /*
    127          * SVG elements: note that TITLE is both an HTML element and an SVG element
    128          * so care must be taken when adding support for either one.
    129          */
    130         $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' );
    131         $this->ensure_support_is_added_everywhere( 'DESC' );
    132         $this->ensure_support_is_added_everywhere( 'TITLE' );
     113        // MathML Elements: MI, MO, MN, MS, MTEXT, ANNOTATION-XML.
     114        $this->ensure_support_is_added_everywhere( 'MATH' );
     115
     116        /*
     117         * SVG elements: note that TITLE is both an HTML element and an SVG element
     118         * so care must be taken when adding support for either one.
     119         *
     120         * FOREIGNOBJECT, DESC, TITLE.
     121         */
     122        $this->ensure_support_is_added_everywhere( 'SVG' );
    133123
    134124        // These elements are specific to list item scope.
     
    162152        $this->ensure_support_is_added_everywhere( 'TEMPLATE' );
    163153
    164         // MathML Elements
    165         $this->ensure_support_is_added_everywhere( 'MI' );
    166         $this->ensure_support_is_added_everywhere( 'MO' );
    167         $this->ensure_support_is_added_everywhere( 'MN' );
    168         $this->ensure_support_is_added_everywhere( 'MS' );
    169         $this->ensure_support_is_added_everywhere( 'MTEXT' );
    170         $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' );
    171 
    172         /*
    173          * SVG elements: note that TITLE is both an HTML element and an SVG element
    174          * so care must be taken when adding support for either one.
    175          */
    176         $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' );
    177         $this->ensure_support_is_added_everywhere( 'DESC' );
    178         $this->ensure_support_is_added_everywhere( 'TITLE' );
     154        // MathML Elements: MI, MO, MN, MS, MTEXT, ANNOTATION-XML.
     155        $this->ensure_support_is_added_everywhere( 'MATH' );
     156
     157        /*
     158         * SVG elements: note that TITLE is both an HTML element and an SVG element
     159         * so care must be taken when adding support for either one.
     160         *
     161         * FOREIGNOBJECT, DESC, TITLE.
     162         */
     163        $this->ensure_support_is_added_everywhere( 'SVG' );
    179164    }
    180165
     
    202187        $this->ensure_support_is_added_everywhere( 'TEMPLATE' );
    203188
    204         // MathML Elements
    205         $this->ensure_support_is_added_everywhere( 'MI' );
    206         $this->ensure_support_is_added_everywhere( 'MO' );
    207         $this->ensure_support_is_added_everywhere( 'MN' );
    208         $this->ensure_support_is_added_everywhere( 'MS' );
    209         $this->ensure_support_is_added_everywhere( 'MTEXT' );
    210         $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' );
    211 
    212         /*
    213          * SVG elements: note that TITLE is both an HTML element and an SVG element
    214          * so care must be taken when adding support for either one.
    215          */
    216         $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' );
    217         $this->ensure_support_is_added_everywhere( 'DESC' );
    218         $this->ensure_support_is_added_everywhere( 'TITLE' );
     189        // MathML Elements: MI, MO, MN, MS, MTEXT, ANNOTATION-XML.
     190        $this->ensure_support_is_added_everywhere( 'MATH' );
     191
     192        /*
     193         * SVG elements: note that TITLE is both an HTML element and an SVG element
     194         * so care must be taken when adding support for either one.
     195         *
     196         * FOREIGNOBJECT, DESC, TITLE.
     197         */
     198        $this->ensure_support_is_added_everywhere( 'SVG' );
    219199    }
    220200
     
    242222        $this->ensure_support_is_added_everywhere( 'TEMPLATE' );
    243223
    244         // MathML Elements
    245         $this->ensure_support_is_added_everywhere( 'MI' );
    246         $this->ensure_support_is_added_everywhere( 'MO' );
    247         $this->ensure_support_is_added_everywhere( 'MN' );
    248         $this->ensure_support_is_added_everywhere( 'MS' );
    249         $this->ensure_support_is_added_everywhere( 'MTEXT' );
    250         $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' );
    251 
    252         /*
    253          * SVG elements: note that TITLE is both an HTML element and an SVG element
    254          * so care must be taken when adding support for either one.
    255          */
    256         $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' );
    257         $this->ensure_support_is_added_everywhere( 'DESC' );
    258         $this->ensure_support_is_added_everywhere( 'TITLE' );
     224        // MathML Elements: MI, MO, MN, MS, MTEXT, ANNOTATION-XML.
     225        $this->ensure_support_is_added_everywhere( 'MATH' );
     226
     227        /*
     228         * SVG elements: note that TITLE is both an HTML element and an SVG element
     229         * so care must be taken when adding support for either one.
     230         *
     231         * FOREIGNOBJECT, DESC, TITLE.
     232         */
     233        $this->ensure_support_is_added_everywhere( 'SVG' );
    259234    }
    260235
     
    281256        $this->ensure_support_is_added_everywhere( 'TEMPLATE' );
    282257
    283         // MathML Elements
    284         $this->ensure_support_is_added_everywhere( 'MI' );
    285         $this->ensure_support_is_added_everywhere( 'MO' );
    286         $this->ensure_support_is_added_everywhere( 'MN' );
    287         $this->ensure_support_is_added_everywhere( 'MS' );
    288         $this->ensure_support_is_added_everywhere( 'MTEXT' );
    289         $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' );
    290 
    291         /*
    292          * SVG elements: note that TITLE is both an HTML element and an SVG element
    293          * so care must be taken when adding support for either one.
    294          */
    295         $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' );
    296         $this->ensure_support_is_added_everywhere( 'DESC' );
    297         $this->ensure_support_is_added_everywhere( 'TITLE' );
     258        // MathML Elements: MI, MO, MN, MS, MTEXT, ANNOTATION-XML.
     259        $this->ensure_support_is_added_everywhere( 'MATH' );
     260
     261        /*
     262         * SVG elements: note that TITLE is both an HTML element and an SVG element
     263         * so care must be taken when adding support for either one.
     264         *
     265         * FOREIGNOBJECT, DESC, TITLE.
     266         */
     267        $this->ensure_support_is_added_everywhere( 'SVG' );
    298268
    299269        // These elements are specific to TABLE scope.
     
    336306        $this->ensure_support_is_added_everywhere( 'TEMPLATE' );
    337307
    338         // MathML Elements
    339         $this->ensure_support_is_added_everywhere( 'MI' );
    340         $this->ensure_support_is_added_everywhere( 'MO' );
    341         $this->ensure_support_is_added_everywhere( 'MN' );
    342         $this->ensure_support_is_added_everywhere( 'MS' );
    343         $this->ensure_support_is_added_everywhere( 'MTEXT' );
    344         $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' );
    345 
    346         /*
    347          * SVG elements: note that TITLE is both an HTML element and an SVG element
    348          * so care must be taken when adding support for either one.
    349          */
    350         $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' );
    351         $this->ensure_support_is_added_everywhere( 'DESC' );
    352         $this->ensure_support_is_added_everywhere( 'TITLE' );
     308        // MathML Elements: MI, MO, MN, MS, MTEXT, ANNOTATION-XML.
     309        $this->ensure_support_is_added_everywhere( 'MATH' );
     310
     311        /*
     312         * SVG elements: note that TITLE is both an HTML element and an SVG element
     313         * so care must be taken when adding support for either one.
     314         *
     315         * FOREIGNOBJECT, DESC, TITLE.
     316         */
     317        $this->ensure_support_is_added_everywhere( 'SVG' );
    353318
    354319        // These elements are specific to SELECT scope.
Note: See TracChangeset for help on using the changeset viewer.