Changeset 55469
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/html-api/class-wp-html-tag-processor.php
r55407 r55469 776 776 } 777 777 778 $at += 2; 778 $closer_potentially_starts_at = $at; 779 $at += 2; 779 780 780 781 /* … … 819 820 820 821 if ( '>' === $html[ $at ] || '/' === $html[ $at ] ) { 821 ++$this->bytes_already_parsed;822 $this->bytes_already_parsed = $closer_potentially_starts_at; 822 823 return true; 823 824 } … … 888 889 889 890 if ( '/' === $html[ $at ] ) { 890 $is_closing = true; 891 $closer_potentially_starts_at = $at - 1; 892 $is_closing = true; 891 893 ++$at; 892 894 } else { … … 939 941 940 942 if ( $is_closing ) { 941 $this->bytes_already_parsed = $ at;943 $this->bytes_already_parsed = $closer_potentially_starts_at; 942 944 if ( $this->bytes_already_parsed >= $doc_length ) { 943 945 return false; … … 949 951 950 952 if ( '>' === $html[ $this->bytes_already_parsed ] ) { 951 ++$this->bytes_already_parsed;953 $this->bytes_already_parsed = $closer_potentially_starts_at; 952 954 return true; 953 955 } -
trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php
r55315 r55469 431 431 /** 432 432 * @ticket 56299 433 * @ticket 57852 433 434 * 434 435 * @covers WP_HTML_Tag_Processor::next_tag … … 460 461 ); 461 462 $this->assertTrue( $p->is_tag_closer(), 'Indicated a tag closer is a tag opener' ); 463 464 $p = new WP_HTML_Tag_Processor( '<div>' ); 465 $this->assertTrue( $p->next_tag( array( 'tag_closers' => 'visit' ) ), "Did not find a tag opener when tag_closers was set to 'visit'" ); 466 $this->assertFalse( $p->next_tag( array( 'tag_closers' => 'visit' ) ), "Found a closer where there wasn't one" ); 467 } 468 469 /** 470 * @ticket 57852 471 * 472 * @covers WP_HTML_Tag_Processor::next_tag 473 * @covers WP_HTML_Tag_Processor::is_tag_closer 474 */ 475 public function test_next_tag_should_stop_on_rcdata_and_script_tag_closers_when_requested() { 476 $p = new WP_HTML_Tag_Processor( '<script>abc</script>' ); 477 478 $p->next_tag(); 479 $this->assertTrue( $p->next_tag( array( 'tag_closers' => 'visit' ) ), 'Did not find the </script> tag closer' ); 480 $this->assertTrue( $p->is_tag_closer(), 'Indicated a <script> tag opener is a tag closer' ); 481 482 $p = new WP_HTML_Tag_Processor( 'abc</script>' ); 483 $this->assertTrue( $p->next_tag( array( 'tag_closers' => 'visit' ) ), 'Did not find the </script> tag closer when there was no tag opener' ); 484 485 $p = new WP_HTML_Tag_Processor( '<textarea>abc</textarea>' ); 486 487 $p->next_tag(); 488 $this->assertTrue( $p->next_tag( array( 'tag_closers' => 'visit' ) ), 'Did not find the </textarea> tag closer' ); 489 $this->assertTrue( $p->is_tag_closer(), 'Indicated a <textarea> tag opener is a tag closer' ); 490 491 $p = new WP_HTML_Tag_Processor( 'abc</textarea>' ); 492 $this->assertTrue( $p->next_tag( array( 'tag_closers' => 'visit' ) ), 'Did not find the </textarea> tag closer when there was no tag opener' ); 493 494 $p = new WP_HTML_Tag_Processor( '<title>abc</title>' ); 495 496 $p->next_tag(); 497 $this->assertTrue( $p->next_tag( array( 'tag_closers' => 'visit' ) ), 'Did not find the </title> tag closer' ); 498 $this->assertTrue( $p->is_tag_closer(), 'Indicated a <title> tag opener is a tag closer' ); 499 500 $p = new WP_HTML_Tag_Processor( 'abc</title>' ); 501 $this->assertTrue( $p->next_tag( array( 'tag_closers' => 'visit' ) ), 'Did not find the </title> tag closer when there was no tag opener' ); 462 502 } 463 503
Note: See TracChangeset
for help on using the changeset viewer.