@@ -1742,20 +1742,36 @@ private function step_in_select() {
17421742 * @return bool Whether an element was found.
17431743 */
17441744 private function step_in_table () {
1745- $ tag_name = $ this ->get_tag ();
1746- $ op_sigil = $ this ->is_tag_closer () ? '- ' : '+ ' ;
1747- $ op = "{$ op_sigil }{$ tag_name }" ;
1745+ $ token_name = $ this ->get_token_name ();
1746+ $ token_type = $ this ->get_token_type ();
1747+ $ op_sigil = '#tag ' === $ token_type ? ( parent ::is_tag_closer () ? '- ' : '+ ' ) : '' ;
1748+ $ op = "{$ op_sigil }{$ token_name }" ;
1749+
17481750
17491751 switch ( $ op ) {
17501752 /*
17511753 * > A character token, if the current node is table, tbody, template, tfoot, thead, or tr element
17521754 */
1755+ case '#text ' :
1756+ $ this ->last_error = self ::ERROR_UNSUPPORTED ;
1757+ throw new WP_HTML_Unsupported_Exception ( "Text in tables is not supported. " );
1758+
17531759 /*
17541760 * > A comment token
17551761 */
1762+ case '#comment ' :
1763+ case '#funky-comment ' :
1764+ $ this ->insert_html_element ( $ this ->state ->current_token );
1765+ return true ;
1766+
1767+
17561768 /*
17571769 * > A DOCTYPE token
17581770 */
1771+ case 'html ' :
1772+ // Parse error. Ignore the token.
1773+ return $ this ->step ();
1774+
17591775 /*
17601776 * > A start tag whose tag name is "caption"
17611777 */
@@ -1873,7 +1889,7 @@ private function step_in_table() {
18731889 case '+INPUT ' :
18741890 $ type_attribute = $ this ->get_attribute ( 'type ' );
18751891 if ( ! is_string ( $ type_attribute ) || 'hidden ' !== strtolower ( $ type_attribute ) ) {
1876- goto in_table_anything_else ;
1892+ break ;
18771893 }
18781894 // parse error
18791895 $ this ->insert_html_element ( $ this ->state ->current_token );
@@ -1897,16 +1913,15 @@ private function step_in_table() {
18971913 * > An end-of-file token
18981914 */
18991915
1900- /*
1901- * > Anything else
1902- * > Parse error. Enable foster parenting, process the token using the rules for the
1903- * > "in body" insertion mode, and then disable foster parenting.
1904- */
1905- default :
1906- in_table_anything_else:
1907- $ this ->last_error = self ::ERROR_UNSUPPORTED ;
1908- throw new WP_HTML_Unsupported_Exception ( "Cannot process {$ tag_name } element. " );
19091916 }
1917+
1918+ /*
1919+ * > Anything else
1920+ * > Parse error. Enable foster parenting, process the token using the rules for the
1921+ * > "in body" insertion mode, and then disable foster parenting.
1922+ */
1923+ $ this ->last_error = self ::ERROR_UNSUPPORTED ;
1924+ throw new WP_HTML_Unsupported_Exception ( "Cannot process {$ tag_name } element. " );
19101925 }
19111926
19121927 /**
0 commit comments