@@ -3068,7 +3068,7 @@ private function step_in_caption(): bool {
3068
3068
* This internal function performs the 'in column group' insertion mode
3069
3069
* logic for the generalized WP_HTML_Processor::step() function.
3070
3070
*
3071
- * @since 6.7.0 Stub implementation.
3071
+ * @since 6.7.0
3072
3072
*
3073
3073
* @throws WP_HTML_Unsupported_Exception When encountering unsupported HTML input.
3074
3074
*
@@ -3078,7 +3078,104 @@ private function step_in_caption(): bool {
3078
3078
* @return bool Whether an element was found.
3079
3079
*/
3080
3080
private function step_in_column_group (): bool {
3081
- $ this ->bail ( 'No support for parsing in the ' . WP_HTML_Processor_State::INSERTION_MODE_IN_COLUMN_GROUP . ' state. ' );
3081
+ $ token_name = $ this ->get_token_name ();
3082
+ $ token_type = $ this ->get_token_type ();
3083
+ $ op_sigil = '#tag ' === $ token_type ? ( parent ::is_tag_closer () ? '- ' : '+ ' ) : '' ;
3084
+ $ op = "{$ op_sigil }{$ token_name }" ;
3085
+
3086
+ switch ( $ op ) {
3087
+ /*
3088
+ * > A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF),
3089
+ * > U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE
3090
+ */
3091
+ case '#text ' :
3092
+ $ text = $ this ->get_modifiable_text ();
3093
+ if ( '' === $ text ) {
3094
+ /*
3095
+ * If the text is empty after processing HTML entities and stripping
3096
+ * U+0000 NULL bytes then ignore the token.
3097
+ */
3098
+ return $ this ->step ();
3099
+ }
3100
+
3101
+ if ( strlen ( $ text ) === strspn ( $ text , " \t\n\f\r" ) ) {
3102
+ // Insert the character.
3103
+ $ this ->insert_html_element ( $ this ->state ->current_token );
3104
+ return true ;
3105
+ }
3106
+
3107
+ goto in_column_group_anything_else;
3108
+ break ;
3109
+
3110
+ /*
3111
+ * > A comment token
3112
+ */
3113
+ case '#comment ' :
3114
+ case '#funky-comment ' :
3115
+ case '#presumptuous-tag ' :
3116
+ $ this ->insert_html_element ( $ this ->state ->current_token );
3117
+ return true ;
3118
+
3119
+ /*
3120
+ * > A DOCTYPE token
3121
+ */
3122
+ case 'html ' :
3123
+ // @todo Indicate a parse error once it's possible.
3124
+ return $ this ->step ();
3125
+
3126
+ /*
3127
+ * > A start tag whose tag name is "html"
3128
+ */
3129
+ case '+HTML ' :
3130
+ return $ this ->step_in_body ();
3131
+
3132
+ /*
3133
+ * > A start tag whose tag name is "col"
3134
+ */
3135
+ case '+COL ' :
3136
+ $ this ->insert_html_element ( $ this ->state ->current_token );
3137
+ $ this ->state ->stack_of_open_elements ->pop ();
3138
+ return true ;
3139
+
3140
+ /*
3141
+ * > An end tag whose tag name is "colgroup"
3142
+ */
3143
+ case '-COLGROUP ' :
3144
+ if ( ! $ this ->state ->stack_of_open_elements ->current_node_is ( 'COLGROUP ' ) ) {
3145
+ // @todo Indicate a parse error once it's possible.
3146
+ return $ this ->step ();
3147
+ }
3148
+ $ this ->state ->stack_of_open_elements ->pop ();
3149
+ $ this ->state ->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_IN_TABLE ;
3150
+ return true ;
3151
+
3152
+ /*
3153
+ * > An end tag whose tag name is "col"
3154
+ */
3155
+ case '-COL ' :
3156
+ // Parse error: ignore the token.
3157
+ return $ this ->step ();
3158
+
3159
+ /*
3160
+ * > A start tag whose tag name is "template"
3161
+ * > An end tag whose tag name is "template"
3162
+ */
3163
+ case '+TEMPLATE ' :
3164
+ case '-TEMPLATE ' :
3165
+ return $ this ->step_in_head ();
3166
+ }
3167
+
3168
+ in_column_group_anything_else:
3169
+ /*
3170
+ * > Anything else
3171
+ */
3172
+ if ( ! $ this ->state ->stack_of_open_elements ->current_node_is ( 'COLGROUP ' ) ) {
3173
+ // @todo Indicate a parse error once it's possible.
3174
+ return $ this ->step ();
3175
+ }
3176
+ $ this ->state ->stack_of_open_elements ->pop ();
3177
+ $ this ->state ->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_IN_TABLE ;
3178
+ return $ this ->step ( self ::REPROCESS_CURRENT_NODE );
3082
3179
}
3083
3180
3084
3181
/**
0 commit comments