Skip to content

Commit 5c7d274

Browse files
committed
Add throw on every special element
1 parent 32dd59b commit 5c7d274

1 file changed

Lines changed: 179 additions & 0 deletions

File tree

src/wp-includes/html-api/class-wp-html-processor.php

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,185 @@ private function step_in_body() {
603603
$op = "{$op_sigil}{$tag_name}";
604604

605605
switch ( $op ) {
606+
/*
607+
* These tags require special handling in the 'in body' insertion mode
608+
* but do not have special handling implemented yet.
609+
*
610+
* We throw the WP_HTML_Unsupported_Exception so we're free to implememnt
611+
* the catch-all handling for any other start and end tag.
612+
*
613+
* @see https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inbody
614+
*/
615+
case '+A':
616+
case '+ADDRESS':
617+
case '+APPLET':
618+
case '+AREA':
619+
case '+ARTICLE':
620+
case '+ASIDE':
621+
case '+B':
622+
case '+BASE':
623+
case '+BASEFONT':
624+
case '+BGSOUND':
625+
case '+BIG':
626+
case '+BLOCKQUOTE':
627+
case '+BODY':
628+
case '+BR':
629+
case '+BUTTON':
630+
case '+CAPTION':
631+
case '+CENTER':
632+
case '+CODE':
633+
case '+COL':
634+
case '+COLGROUP':
635+
case '+DD':
636+
case '+DETAILS':
637+
case '+DIALOG':
638+
case '+DIR':
639+
case '+DIV':
640+
case '+DL':
641+
case '+DT':
642+
case '+EM':
643+
case '+EMBED':
644+
case '+FIELDSET':
645+
case '+FIGCAPTION':
646+
case '+FIGURE':
647+
case '+FONT':
648+
case '+FOOTER':
649+
case '+FORM':
650+
case '+FRAME':
651+
case '+FRAMESET':
652+
case '+H1':
653+
case '+H2':
654+
case '+H3':
655+
case '+H4':
656+
case '+H5':
657+
case '+H6':
658+
case '+HEAD':
659+
case '+HEADER':
660+
case '+HGROUP':
661+
case '+HR':
662+
case '+HTML':
663+
case '+I':
664+
case '+IFRAME':
665+
case '+IMAGE':
666+
case '+IMG':
667+
case '+INPUT':
668+
case '+KEYGEN':
669+
case '+LI':
670+
case '+LINK':
671+
case '+LISTING':
672+
case '+MAIN':
673+
case '+MARQUEE':
674+
case '+MATH':
675+
case '+MENU':
676+
case '+META':
677+
case '+NAV':
678+
case '+NOBR':
679+
case '+NOEMBED':
680+
case '+NOFRAMES':
681+
case '+NOSCRIPT': // scripting flag??
682+
case '+OBJECT':
683+
case '+OL':
684+
case '+OPTGROUP':
685+
case '+OPTION':
686+
case '+P':
687+
case '+PARAM':
688+
case '+PLAINTEXT':
689+
case '+PRE':
690+
case '+RB':
691+
case '+RP':
692+
case '+RT':
693+
case '+RTC':
694+
case '+S':
695+
case '+SCRIPT':
696+
case '+SEARCH':
697+
case '+SECTION':
698+
case '+SELECT':
699+
case '+SMALL':
700+
case '+SOURCE':
701+
case '+STRIKE':
702+
case '+STRONG':
703+
case '+STYLE':
704+
case '+SUMMARY':
705+
case '+SVG':
706+
case '+TABLE':
707+
case '+TBODY':
708+
case '+TD':
709+
case '+TEMPLATE':
710+
case '+TEXTAREA':
711+
case '+TFOOT':
712+
case '+TH':
713+
case '+THEAD':
714+
case '+TITLE':
715+
case '+TR':
716+
case '+TRACK':
717+
case '+TT':
718+
case '+U':
719+
case '+UL':
720+
case '+WBR':
721+
case '+XMP':
722+
case '-A':
723+
case '-ADDRESS':
724+
case '-APPLET':
725+
case '-ARTICLE':
726+
case '-ASIDE':
727+
case '-B':
728+
case '-BIG':
729+
case '-BLOCKQUOTE':
730+
case '-BODY':
731+
case '-BR':
732+
case '-BUTTON':
733+
case '-CENTER':
734+
case '-CODE':
735+
case '-DD':
736+
case '-DETAILS':
737+
case '-DIALOG':
738+
case '-DIR':
739+
case '-DIV':
740+
case '-DL':
741+
case '-DT':
742+
case '-EM':
743+
case '-FIELDSET':
744+
case '-FIGCAPTION':
745+
case '-FIGURE':
746+
case '-FONT':
747+
case '-FOOTER':
748+
case '-FORM':
749+
case '-H1':
750+
case '-H2':
751+
case '-H3':
752+
case '-H4':
753+
case '-H5':
754+
case '-H6':
755+
case '-HEADER':
756+
case '-HGROUP':
757+
case '-HTML':
758+
case '-I':
759+
case '-LI':
760+
case '-LISTING':
761+
case '-MAIN':
762+
case '-MARQUEE':
763+
case '-MENU':
764+
case '-NAV':
765+
case '-NOBR':
766+
case '-OBJECT':
767+
case '-OL':
768+
case '-P':
769+
case '-PRE':
770+
case '-S':
771+
case '-SEARCH':
772+
case '-SECTION':
773+
case '-SMALL':
774+
case '-STRIKE':
775+
case '-STRONG':
776+
case '-SUMMARY':
777+
case '-TEMPLATE':
778+
case '-TT':
779+
case '-U':
780+
case '-UL':
781+
$this->last_error = self::ERROR_UNSUPPORTED;
782+
throw new WP_HTML_Unsupported_Exception( "Cannot process {$tag_name} element." );
783+
784+
606785
/*
607786
* > A start tag whose tag name is "button"
608787
*/

0 commit comments

Comments
 (0)