Ticket #20009: 20009.4.diff
| File 20009.4.diff, 3.3 KB (added by , 6 years ago) |
|---|
-
src/wp-includes/post-template.php
454 454 */ 455 455 function post_class( $class = '', $post_id = null ) { 456 456 // Separates classes with a single space, collates classes for post DIV. 457 echo 'class="' . join( ' ', get_post_class( $class, $post_id) ) . '"';457 echo 'class="' . esc_attr( join( ' ', get_post_class( $class, $post_id ) ) ) . '"'; 458 458 } 459 459 460 460 /** … … 590 590 */ 591 591 function body_class( $class = '' ) { 592 592 // Separates class names with a single space, collates class names for body element. 593 echo 'class="' . join( ' ', get_body_class( $class) ) . '"';593 echo 'class="' . esc_attr( join( ' ', get_body_class( $class ) ) ) . '"'; 594 594 } 595 595 596 596 /** -
tests/phpunit/tests/post/bodyClass.php
1 <?php 2 3 /** 4 * @group post 5 * @covers ::body_class 6 */ 7 class Tests_Post_BodyClass extends WP_UnitTestCase { 8 protected $post_id; 9 10 public function setUp() { 11 parent::setUp(); 12 $this->post_id = self::factory()->post->create(); 13 } 14 15 public function test_body_class() { 16 $expected = 'class="' . join( ' ', get_body_class( '', $this->post_id ) ) . '"'; 17 $this->expectOutputString( $expected ); 18 body_class( '', $this->post_id ); 19 } 20 21 public function test_body_class_extra_esc_attr() { 22 $classes = get_body_class( '', $this->post_id ); 23 $escaped_again = array_map( 'esc_attr', $classes ); 24 $escaped_another_time = 'class="' . esc_attr( join( ' ', $escaped_again ) ) . '"'; 25 26 $this->expectOutputString( $escaped_another_time ); 27 body_class( '', $this->post_id ); 28 } 29 } -
tests/phpunit/tests/post/postClass.php
Property changes on: tests/phpunit/tests/post/bodyClass.php ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 <?php 2 3 /** 4 * @group post 5 * @covers ::post_class 6 */ 7 class Tests_Post_PostClass extends WP_UnitTestCase { 8 protected $post_id; 9 10 public function setUp() { 11 parent::setUp(); 12 $this->post_id = self::factory()->post->create(); 13 } 14 15 public function test_post_class() { 16 $expected = 'class="' . join( ' ', get_post_class( '', $this->post_id ) ) . '"'; 17 $this->expectOutputString( $expected ); 18 post_class( '', $this->post_id ); 19 } 20 21 public function test_post_class_extra_esc_attr() { 22 $classes = get_post_class( '', $this->post_id ); 23 $escaped_again = array_map( 'esc_attr', $classes ); 24 $escaped_another_time = 'class="' . esc_attr( join( ' ', $escaped_again ) ) . '"'; 25 26 $this->expectOutputString( $escaped_another_time ); 27 post_class( '', $this->post_id ); 28 } 29 }
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)