diff --git a/src/wp-includes/widgets.php b/src/wp-includes/widgets.php index 5bf9d16b31393..f7ea7095669c8 100644 --- a/src/wp-includes/widgets.php +++ b/src/wp-includes/widgets.php @@ -1644,7 +1644,8 @@ function wp_widget_rss_output( $rss, $args = array() ) { } $link = esc_url( strip_tags( $link ) ); - $title = esc_html( trim( strip_tags( $item->get_title() ) ) ); + $title = esc_html( trim( strip_tags( html_entity_decode( $item->get_title() ) ) ) ); + if ( empty( $title ) ) { $title = __( 'Untitled' ); } diff --git a/tests/phpunit/tests/widgets/wpWidgetRss.php b/tests/phpunit/tests/widgets/wpWidgetRss.php index 7135e4b702f35..9870ec92a1674 100644 --- a/tests/phpunit/tests/widgets/wpWidgetRss.php +++ b/tests/phpunit/tests/widgets/wpWidgetRss.php @@ -116,4 +116,47 @@ public function mocked_rss_response() { 'filename' => null, ); } + + /** + * @ticket 63611 + * @covers wp_widget_rss_output + */ + public function test_rss_title_html_entities_decoded() { + $mock_item = $this->getMockBuilder( 'SimplePie_Item' ) + ->disableOriginalConstructor() + ->getMock(); + + $mock_item->method( 'get_title' ) + ->willReturn( 'Title with <em>HTML entities</em>' ); + + $mock_item->method( 'get_link' ) + ->willReturn( 'https://example.com' ); + + $mock_item->method( 'get_description' ) + ->willReturn( 'Description' ); + + $mock_item->method( 'get_date' ) + ->willReturn( false ); + + $mock_item->method( 'get_author' ) + ->willReturn( false ); + + $mock_rss = $this->getMockBuilder( 'SimplePie' ) + ->disableOriginalConstructor() + ->getMock(); + + $mock_rss->method( 'get_item_quantity' ) + ->willReturn( 1 ); + + $mock_rss->method( 'get_items' ) + ->willReturn( array( $mock_item ) ); + + ob_start(); + wp_widget_rss_output( $mock_rss ); + $output = ob_get_clean(); + + $this->assertStringContainsString( 'Title with HTML entities', $output ); + $this->assertStringNotContainsString( '<em>', $output ); + $this->assertStringNotContainsString( '</em>', $output ); + } }