Make WordPress Core

Ticket #30210: 30210.5.patch

File 30210.5.patch, 1.0 KB (added by stevenkword, 7 years ago)
  • src/wp-includes/functions.php

     
    12041204function do_feed() {
    12051205        global $wp_query;
    12061206
     1207        // Determine if we are looking at the main comment feed
     1208        $is_main_comments_feed = ( $wp_query->is_comment_feed() && ! $wp_query->is_singular() ) ? true : false;
     1209
     1210        /*
     1211         * Check the queried object for the existence of posts if it is not a feed for an archive,
     1212         * search result, or main comments. By checking for the absense of posts we can prevent rendering the feed
     1213         * templates at invalid endpoints. e.g.) /wp-content/plugins/feed/
     1214         *
     1215         */
     1216        if ( ! $wp_query->have_posts() && ! ( $wp_query->is_archive() || $wp_query->is_post_type_archive() || $wp_query->is_search() || $is_main_comments_feed ) ) {
     1217                wp_die( __( 'ERROR: This is not a valid feed.' ), '', array( 'response' => 404 ) );
     1218        }
     1219
    12071220        $feed = get_query_var( 'feed' );
    12081221
    12091222        // Remove the pad, if present.