Skip to content

Commit af1dd16

Browse files
committed
Rework to use tag name
1 parent a8a176f commit af1dd16

1 file changed

Lines changed: 86 additions & 107 deletions

File tree

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

Lines changed: 86 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -603,112 +603,6 @@ 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 '+APPLET':
616-
case '+AREA':
617-
case '+BASE':
618-
case '+BASEFONT':
619-
case '+BGSOUND':
620-
case '+BLOCKQUOTE':
621-
case '+BODY':
622-
case '+BR':
623-
case '+CAPTION':
624-
case '+COL':
625-
case '+COLGROUP':
626-
case '+DD':
627-
case '+DT':
628-
case '+EMBED':
629-
case '+FORM':
630-
case '+FRAME':
631-
case '+FRAMESET':
632-
case '+H1':
633-
case '+H2':
634-
case '+H3':
635-
case '+H4':
636-
case '+H5':
637-
case '+H6':
638-
case '+HEAD':
639-
case '+HR':
640-
case '+HTML':
641-
case '+IFRAME':
642-
case '+IMAGE':
643-
case '+INPUT':
644-
case '+KEYGEN':
645-
case '+LI':
646-
case '+LINK':
647-
case '+LISTING':
648-
case '+MARQUEE':
649-
case '+MATH':
650-
case '+META':
651-
case '+NOBR':
652-
case '+NOEMBED':
653-
case '+NOFRAMES':
654-
case '+NOSCRIPT': // scripting flag??
655-
case '+OBJECT':
656-
case '+OL':
657-
case '+OPTGROUP':
658-
case '+OPTION':
659-
case '+PARAM':
660-
case '+PLAINTEXT':
661-
case '+PRE':
662-
case '+RB':
663-
case '+RP':
664-
case '+RT':
665-
case '+RTC':
666-
case '+SCRIPT':
667-
case '+SELECT':
668-
case '+SOURCE':
669-
case '+STYLE':
670-
case '+SVG':
671-
case '+TABLE':
672-
case '+TBODY':
673-
case '+TD':
674-
case '+TEMPLATE':
675-
case '+TEXTAREA':
676-
case '+TFOOT':
677-
case '+TH':
678-
case '+THEAD':
679-
case '+TITLE':
680-
case '+TR':
681-
case '+TRACK':
682-
case '+UL':
683-
case '+WBR':
684-
case '+XMP':
685-
case '-APPLET':
686-
case '-BLOCKQUOTE':
687-
case '-BODY':
688-
case '-BR':
689-
case '-DD':
690-
case '-DT':
691-
case '-FORM':
692-
case '-H1':
693-
case '-H2':
694-
case '-H3':
695-
case '-H4':
696-
case '-H5':
697-
case '-H6':
698-
case '-HTML':
699-
case '-LI':
700-
case '-LISTING':
701-
case '-MARQUEE':
702-
case '-NOBR':
703-
case '-OBJECT':
704-
case '-OL':
705-
case '-PRE':
706-
case '-TEMPLATE':
707-
case '-UL':
708-
$this->last_error = self::ERROR_UNSUPPORTED;
709-
throw new WP_HTML_Unsupported_Exception( "Cannot process {$tag_name} element." );
710-
711-
712606
/*
713607
* > A start tag whose tag name is "button"
714608
*/
@@ -968,10 +862,95 @@ private function step_in_body() {
968862
// Execution should not reach here; if it does then something went wrong.
969863
return false;
970864

971-
default:
865+
}
866+
867+
/*
868+
* These tags require special handling in the 'in body' insertion mode
869+
* that has not been implemented yet.
870+
*
871+
* As they're implemented, they should be removed from this list. An accompanying
872+
* test should help with this.
873+
*
874+
* We throw the WP_HTML_Unsupported_Exception so we're free to implememnt
875+
* the catch-all handling for any other start and end tag.
876+
*
877+
* @see https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inbody
878+
*/
879+
switch ( $tag_name ) {
880+
case 'APPLET':
881+
case 'AREA':
882+
case 'BASE':
883+
case 'BASEFONT':
884+
case 'BGSOUND':
885+
case 'BODY':
886+
case 'BR':
887+
case 'CAPTION':
888+
case 'COL':
889+
case 'COLGROUP':
890+
case 'DD':
891+
case 'DT':
892+
case 'EMBED':
893+
case 'FORM':
894+
case 'FRAME':
895+
case 'FRAMESET':
896+
case 'H1':
897+
case 'H2':
898+
case 'H3':
899+
case 'H4':
900+
case 'H5':
901+
case 'H6':
902+
case 'HEAD':
903+
case 'HR':
904+
case 'HTML':
905+
case 'IFRAME':
906+
case 'INPUT':
907+
case 'KEYGEN':
908+
case 'LI':
909+
case 'LINK':
910+
case 'LISTING':
911+
case 'MARQUEE':
912+
case 'MATH':
913+
case 'META':
914+
case 'NOBR':
915+
case 'NOEMBED':
916+
case 'NOFRAMES':
917+
case 'NOSCRIPT':
918+
case 'OBJECT':
919+
case 'OL':
920+
case 'OPTGROUP':
921+
case 'OPTION':
922+
case 'PARAM':
923+
case 'PLAINTEXT':
924+
case 'PRE':
925+
case 'RB':
926+
case 'RP':
927+
case 'RT':
928+
case 'RTC':
929+
case 'SCRIPT':
930+
case 'SELECT':
931+
case 'SOURCE':
932+
case 'STYLE':
933+
case 'SVG':
934+
case 'TABLE':
935+
case 'TBODY':
936+
case 'TD':
937+
case 'TEMPLATE':
938+
case 'TEXTAREA':
939+
case 'TFOOT':
940+
case 'TH':
941+
case 'THEAD':
942+
case 'TITLE':
943+
case 'TR':
944+
case 'TRACK':
945+
case 'UL':
946+
case 'WBR':
947+
case 'XMP':
972948
$this->last_error = self::ERROR_UNSUPPORTED;
973949
throw new WP_HTML_Unsupported_Exception( "Cannot process {$tag_name} element." );
974950
}
951+
952+
$this->last_error = self::ERROR_UNSUPPORTED;
953+
throw new WP_HTML_Unsupported_Exception( "Cannot process {$tag_name} element." );
975954
}
976955

977956
/*

0 commit comments

Comments
 (0)