Changeset 57316
- Timestamp:
- 01/19/2024 09:40:01 PM (10 months ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/html-api/class-wp-html-processor.php
r57314 r57316 103 103 * - Custom elements: All custom elements are supported. :) 104 104 * - Form elements: BUTTON, DATALIST, FIELDSET, LABEL, LEGEND, METER, PROGRESS, SEARCH. 105 * - Formatting elements: B, BIG, CODE, EM, FONT, I, SMALL, STRIKE, STRONG, TT, U .105 * - Formatting elements: B, BIG, CODE, EM, FONT, I, SMALL, STRIKE, STRONG, TT, U, WBR. 106 106 * - Heading elements: H1, H2, H3, H4, H5, H6, HGROUP. 107 107 * - Links: A. 108 108 * - Lists: DD, DL, DT, LI, OL, LI. 109 * - Media elements: AUDIO, CANVAS, FIGCAPTION, FIGURE, IMG, MAP, PICTURE, VIDEO.110 * - Paragraph: P.111 * - Phrasing elements: A BBR, BDI, BDO, CITE, DATA, DEL, DFN, INS, MARK, OUTPUT, Q, SAMP, SUB, SUP, TIME, VAR.109 * - Media elements: AUDIO, CANVAS, EMBED, FIGCAPTION, FIGURE, IMG, MAP, PICTURE, VIDEO. 110 * - Paragraph: BR, P. 111 * - Phrasing elements: AREA, ABBR, BDI, BDO, CITE, DATA, DEL, DFN, INS, MARK, OUTPUT, Q, SAMP, SUB, SUP, TIME, VAR. 112 112 * - Sectioning elements: ARTICLE, ASIDE, HR, NAV, SECTION. 113 113 * - Templating elements: SLOT. 114 114 * - Text decoration: RUBY. 115 * - Deprecated elements: ACRONYM, BLINK, CENTER, DIR, ISINDEX, MULTICOL, NEXTID, SPACER.115 * - Deprecated elements: ACRONYM, BLINK, CENTER, DIR, ISINDEX, KEYGEN, MULTICOL, NEXTID, SPACER. 116 116 * 117 117 * ### Supported markup … … 936 936 937 937 /* 938 * > An end tag whose tag name is "br" 939 * > Parse error. Drop the attributes from the token, and act as described in the next 940 * > entry; i.e. act as if this was a "br" start tag token with no attributes, rather 941 * > than the end tag token that it actually is. 942 */ 943 case '-BR': 944 $this->last_error = self::ERROR_UNSUPPORTED; 945 throw new WP_HTML_Unsupported_Exception( 'Closing BR tags require unimplemented special handling.' ); 946 947 /* 938 948 * > A start tag whose tag name is one of: "area", "br", "embed", "img", "keygen", "wbr" 939 949 */ 950 case '+AREA': 951 case '+BR': 952 case '+EMBED': 940 953 case '+IMG': 954 case '+KEYGEN': 955 case '+WBR': 941 956 $this->reconstruct_active_formatting_elements(); 942 957 $this->insert_html_element( $this->state->current_token ); 958 $this->state->frameset_ok = false; 943 959 return true; 944 960 … … 978 994 case 'BGSOUND': 979 995 case 'BODY': 980 case 'BR':981 996 case 'CAPTION': 982 997 case 'COL': … … 984 999 case 'DD': 985 1000 case 'DT': 986 case 'EMBED':987 1001 case 'FORM': 988 1002 case 'FRAME': … … 992 1006 case 'IFRAME': 993 1007 case 'INPUT': 994 case 'KEYGEN':995 1008 case 'LI': 996 1009 case 'LINK': … … 1032 1045 case 'TRACK': 1033 1046 case 'UL': 1034 case 'WBR':1035 1047 case 'XMP': 1036 1048 $this->last_error = self::ERROR_UNSUPPORTED; … … 1693 1705 'INPUT' === $tag_name || 1694 1706 'LINK' === $tag_name || 1707 'KEYGEN' === $tag_name || // Obsolete but still treated as void. 1695 1708 'META' === $tag_name || 1696 1709 'SOURCE' === $tag_name || -
trunk/tests/phpunit/tests/html-api/wpHtmlProcessor.php
r57314 r57316 134 134 135 135 /** 136 * Ensure non-nesting tags do not nest. 137 * 138 * @ticket 60283 139 * 140 * @covers WP_HTML_Processor::step_in_body 141 * @covers WP_HTML_Processor::is_void 142 * 143 * @dataProvider data_void_tags 144 * 145 * @param string $tag_name Name of void tag under test. 146 */ 147 public function test_cannot_nest_void_tags( $tag_name ) { 148 $processor = WP_HTML_Processor::create_fragment( "<{$tag_name}><div>" ); 149 150 /* 151 * This HTML represents the same as the following HTML, 152 * assuming that it were provided `<img>` as the tag: 153 * 154 * <html> 155 * <body> 156 * <img> 157 * <div></div> 158 * </body> 159 * </html> 160 */ 161 162 $found_tag = $processor->next_tag(); 163 164 if ( WP_HTML_Processor::ERROR_UNSUPPORTED === $processor->get_last_error() ) { 165 $this->markTestSkipped( "Tag {$tag_name} is not supported." ); 166 } 167 168 $this->assertTrue( 169 $found_tag, 170 "Could not find first {$tag_name}." 171 ); 172 173 $this->assertSame( 174 array( 'HTML', 'BODY', $tag_name ), 175 $processor->get_breadcrumbs(), 176 'Found incorrect nesting of first element.' 177 ); 178 179 $this->assertTrue( 180 $processor->next_tag(), 181 'Should have found the DIV as the second tag.' 182 ); 183 184 $this->assertSame( 185 array( 'HTML', 'BODY', 'DIV' ), 186 $processor->get_breadcrumbs(), 187 "DIV should have been a sibling of the {$tag_name}." 188 ); 189 } 190 191 /** 192 * Data provider. 193 * 194 * @return array[] 195 */ 196 public function data_void_tags() { 197 return array( 198 'AREA' => array( 'AREA' ), 199 'BASE' => array( 'BASE' ), 200 'BR' => array( 'BR' ), 201 'COL' => array( 'COL' ), 202 'EMBED' => array( 'EMBED' ), 203 'HR' => array( 'HR' ), 204 'IMG' => array( 'IMG' ), 205 'INPUT' => array( 'INPUT' ), 206 'KEYGEN' => array( 'KEYGEN' ), 207 'LINK' => array( 'LINK' ), 208 'META' => array( 'META' ), 209 'SOURCE' => array( 'SOURCE' ), 210 'TRACK' => array( 'TRACK' ), 211 'WBR' => array( 'WBR' ), 212 ); 213 } 214 215 /** 136 216 * Ensures that special handling of unsupported tags is cleaned up 137 217 * as handling is implemented. Otherwise there's risk of leaving special … … 160 240 return array( 161 241 'APPLET' => array( 'APPLET' ), 162 'AREA' => array( 'AREA' ),163 242 'BASE' => array( 'BASE' ), 164 243 'BASEFONT' => array( 'BASEFONT' ), 165 244 'BGSOUND' => array( 'BGSOUND' ), 166 245 'BODY' => array( 'BODY' ), 167 'BR' => array( 'BR' ),168 246 'CAPTION' => array( 'CAPTION' ), 169 247 'COL' => array( 'COL' ), 170 248 'COLGROUP' => array( 'COLGROUP' ), 171 'EMBED' => array( 'EMBED' ),172 249 'FORM' => array( 'FORM' ), 173 250 'FRAME' => array( 'FRAME' ), … … 177 254 'IFRAME' => array( 'IFRAME' ), 178 255 'INPUT' => array( 'INPUT' ), 179 'KEYGEN' => array( 'KEYGEN' ),180 256 'LINK' => array( 'LINK' ), 181 257 'LISTING' => array( 'LISTING' ), … … 214 290 'TR' => array( 'TR' ), 215 291 'TRACK' => array( 'TRACK' ), 216 'WBR' => array( 'WBR' ),217 292 'XMP' => array( 'XMP' ), 218 293 ); -
trunk/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php
r57314 r57316 163 163 $unsupported_elements = array( 164 164 'APPLET', // Deprecated. 165 'AREA',166 165 'BASE', 167 166 'BGSOUND', // Deprecated; self-closing if self-closing flag provided, otherwise normal. 168 167 'BODY', 169 'BR',170 168 'CAPTION', 171 169 'COL', 172 170 'COLGROUP', 173 'EMBED',174 171 'FORM', 175 172 'FRAME', … … 179 176 'IFRAME', 180 177 'INPUT', 181 'KEYGEN', // Deprecated; void.182 178 'LINK', 183 179 'LISTING', // Deprecated, use PRE instead. … … 214 210 'TR', 215 211 'TRACK', 216 'WBR',217 212 'XMP', // Deprecated, use PRE instead. 218 213 ); -
trunk/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php
r57314 r57316 393 393 $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'DIV' ), $p->get_breadcrumbs(), 'Failed to produce expected DOM nesting: SPAN should be closed and DIV should be its sibling.' ); 394 394 } 395 396 /** 397 * Ensures that support isn't accidentally partially added for the closing BR tag `</br>`. 398 * 399 * This tag closer has special rules and support shouldn't be added without implementing full support. 400 * 401 * > An end tag whose tag name is "br" 402 * > Parse error. Drop the attributes from the token, and act as described in the next entry; 403 * > i.e. act as if this was a "br" start tag token with no attributes, rather than the end 404 * > tag token that it actually is. 405 * 406 * When this handling is implemented, this test should be removed. It's not incorporated 407 * into the existing unsupported tag behavior test because the opening tag is supported; 408 * only the closing tag isn't. 409 * 410 * @covers WP_HTML_Processor::step_in_body 411 * 412 * @ticket 60283 413 */ 414 public function test_br_end_tag_unsupported() { 415 $p = WP_HTML_Processor::create_fragment( '</br>' ); 416 417 $this->assertFalse( $p->next_tag(), 'Found a BR tag that should not be handled.' ); 418 $this->assertSame( WP_HTML_Processor::ERROR_UNSUPPORTED, $p->get_last_error() ); 419 } 395 420 }
Note: See TracChangeset
for help on using the changeset viewer.