Changeset 59401
- Timestamp:
- 11/13/2024 04:13:52 PM (2 months ago)
- Location:
- branches/6.7
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/6.7
-
branches/6.7/src/wp-includes/html-api/class-wp-html-processor.php
r59248 r59401 1158 1158 1159 1159 switch ( $token_type ) { 1160 case '#doctype': 1161 $doctype = $this->get_doctype_info(); 1162 if ( null === $doctype ) { 1163 break; 1164 } 1165 1166 $html .= '<!DOCTYPE'; 1167 1168 if ( $doctype->name ) { 1169 $html .= " {$doctype->name}"; 1170 } 1171 1172 if ( null !== $doctype->public_identifier ) { 1173 $html .= " PUBLIC \"{$doctype->public_identifier}\""; 1174 } 1175 if ( null !== $doctype->system_identifier ) { 1176 if ( null === $doctype->public_identifier ) { 1177 $html .= ' SYSTEM'; 1178 } 1179 $html .= " \"{$doctype->system_identifier}\""; 1180 } 1181 $html .= '>'; 1182 break; 1183 1160 1184 case '#text': 1161 1185 $html .= htmlspecialchars( $this->get_modifiable_text(), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5, 'UTF-8' ); … … 1173 1197 case '#cdata-section': 1174 1198 $html .= "<![CDATA[{$this->get_modifiable_text()}]]>"; 1175 break;1176 1177 case 'html':1178 $html .= '<!DOCTYPE html>';1179 1199 break; 1180 1200 } -
branches/6.7/tests/phpunit/tests/html-api/wpHtmlProcessor-serialize.php
r59076 r59401 285 285 ); 286 286 } 287 288 /** 289 * @ticket 62396 290 * 291 * @dataProvider data_provider_serialize_doctype 292 */ 293 public function test_full_document_serialize_includes_doctype( string $doctype_input, string $doctype_output ) { 294 $processor = WP_HTML_Processor::create_full_parser( 295 "{$doctype_input}👌" 296 ); 297 $this->assertSame( 298 "{$doctype_output}<html><head></head><body>👌</body></html>", 299 $processor->serialize() 300 ); 301 } 302 303 /** 304 * Data provider. 305 * 306 * @return array[] 307 */ 308 public static function data_provider_serialize_doctype() { 309 return array( 310 'None' => array( '', '' ), 311 'Empty' => array( '<!DOCTYPE>', '<!DOCTYPE>' ), 312 'HTML5' => array( '<!DOCTYPE html>', '<!DOCTYPE html>' ), 313 'Strange name' => array( '<!DOCTYPE WordPress>', '<!DOCTYPE wordpress>' ), 314 'With public' => array( '<!DOCTYPE html PUBLIC "x">', '<!DOCTYPE html PUBLIC "x">' ), 315 'With system' => array( '<!DOCTYPE html SYSTEM "y">', '<!DOCTYPE html SYSTEM "y">' ), 316 'With public and system' => array( '<!DOCTYPE html PUBLIC "x" "y">', '<!DOCTYPE html PUBLIC "x" "y">' ), 317 'Weird casing' => array( '<!docType HtmL pubLIc\'xxx\'"yyy" all this is ignored>', '<!DOCTYPE html PUBLIC "xxx" "yyy">' ), 318 ); 319 } 287 320 }
Note: See TracChangeset
for help on using the changeset viewer.