Changeset 60887
- Timestamp:
- 10/01/2025 12:57:19 PM (7 weeks ago)
- Location:
- trunk
- Files:
-
- 4 edited
- src/wp-includes/html-api/class-wp-html-processor.php (modified) (2 diffs)
- src/wp-includes/html-api/class-wp-html-tag-processor.php (modified) (1 diff)
- tests/phpunit/tests/html-api/wpHtmlProcessor.php (modified) (1 diff)
- tests/phpunit/tests/html-api/wpHtmlTagProcessor.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/html-api/class-wp-html-processor.php
r60647 r60887 298 298 } 299 299 300 if ( ! is_string( $html ) ) { 301 _doing_it_wrong( 302 __METHOD__, 303 __( 'The HTML parameter must be a string.' ), 304 '6.9.0' 305 ); 306 return null; 307 } 308 300 309 $context_processor = static::create_full_parser( "<!DOCTYPE html>{$context}", $encoding ); 301 310 if ( null === $context_processor ) { … … 338 347 public static function create_full_parser( $html, $known_definite_encoding = 'UTF-8' ) { 339 348 if ( 'UTF-8' !== $known_definite_encoding ) { 349 return null; 350 } 351 if ( ! is_string( $html ) ) { 352 _doing_it_wrong( 353 __METHOD__, 354 __( 'The HTML parameter must be a string.' ), 355 '6.9.0' 356 ); 340 357 return null; 341 358 } -
trunk/src/wp-includes/html-api/class-wp-html-tag-processor.php
r60706 r60887 835 835 */ 836 836 public function __construct( $html ) { 837 if ( ! is_string( $html ) ) { 838 _doing_it_wrong( 839 __METHOD__, 840 __( 'The HTML parameter must be a string.' ), 841 '6.9.0' 842 ); 843 $html = ''; 844 } 837 845 $this->html = $html; 838 846 } -
trunk/tests/phpunit/tests/html-api/wpHtmlProcessor.php
r59467 r60887 35 35 public function test_warns_that_the_static_creator_methods_should_be_called_instead_of_the_public_constructor() { 36 36 new WP_HTML_Processor( '<p>Light roast.</p>' ); 37 } 38 39 /** 40 * @ticket 63854 41 * 42 * @covers ::create_fragment 43 * @expectedIncorrectUsage WP_HTML_Processor::create_fragment 44 */ 45 public function test_create_fragment_validates_html_parameter() { 46 $processor = WP_HTML_Processor::create_fragment( null ); 47 $this->assertNull( $processor ); 48 } 49 50 /** 51 * @ticket 63854 52 * 53 * @covers ::create_full_parser 54 * @expectedIncorrectUsage WP_HTML_Processor::create_full_parser 55 */ 56 public function test_create_full_parser_validates_html_parameter() { 57 $processor = WP_HTML_Processor::create_full_parser( null ); 58 $this->assertNull( $processor ); 37 59 } 38 60 -
trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php
r60649 r60887 71 71 $this->assertFalse( $processor->has_self_closing_flag(), 'Found the self-closing tag when it was absent.' ); 72 72 } 73 } 74 75 /** 76 * @ticket 63854 77 * 78 * @covers WP_HTML_Tag_Processor::__construct 79 * @expectedIncorrectUsage WP_HTML_Tag_Processor::__construct 80 */ 81 public function test_constructor_validates_html_parameter() { 82 // Test that passing null triggers _doing_it_wrong and sets HTML to empty string. 83 $processor = new WP_HTML_Tag_Processor( null ); 84 85 // Verify that the HTML was set to an empty string. 86 $this->assertSame( '', $processor->get_updated_html(), 'HTML should be set to empty string when null is passed' ); 87 88 // Verify that next_token() works without errors (indicating the processor is in a valid state). 89 $this->assertFalse( $processor->next_token(), 'next_token() should work without errors when HTML is empty string' ); 73 90 } 74 91
Note: See TracChangeset for help on using the changeset viewer.