diff --git a/src/wp-includes/feed.php b/src/wp-includes/feed.php index 7ef7059ce45bd..676fb25f0ea41 100644 --- a/src/wp-includes/feed.php +++ b/src/wp-includes/feed.php @@ -837,8 +837,14 @@ function fetch_feed( $url ) { */ do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) ); + $blog_charset = get_bloginfo( 'charset' ); + + if ( empty( $blog_charset ) ) { + $blog_charset = 'UTF-8'; + } + $feed->init(); - $feed->set_output_encoding( get_option( 'blog_charset' ) ); + $feed->set_output_encoding( $blog_charset ); if ( $feed->error() ) { return new WP_Error( 'simplepie-error', $feed->error() ); diff --git a/tests/phpunit/tests/feed/fetchFeed.php b/tests/phpunit/tests/feed/fetchFeed.php new file mode 100644 index 0000000000000..c410c7b955183 --- /dev/null +++ b/tests/phpunit/tests/feed/fetchFeed.php @@ -0,0 +1,45 @@ + 'application/rss+xml; charset=UTF-8', + 'link' => '; rel="https://api.w.org/"', + ); + + return array( + 'headers' => new WpOrg\Requests\Utility\CaseInsensitiveDictionary( $single_value_headers ), + 'body' => file_get_contents( DIR_TESTDATA . '/feed/wordpress-org-news.xml' ), + 'response' => array( + 'code' => 200, + 'message' => 'OK', + ), + 'cookies' => array(), + 'filename' => null, + ); + } +}