WordPress.org

Make WordPress Core

Ticket #30210: 30210.3.patch

File 30210.3.patch, 871 bytes (added by stevenkword, 5 years ago)
  • src/wp-includes/functions.php

     
    12041204function do_feed() {
    12051205        global $wp_query;
    12061206
     1207        /*
     1208         * Check the queried object for the existence of posts if it is not a feed for an archive
     1209         * or search result. By checking for the absense of posts we can prevent rendering the feed
     1210         * templates at invalid endpoints. e.g.) /wp-content/plugins/feed/
     1211         */
     1212        if ( ! $wp_query->have_posts() && ! ( $wp_query->is_category() || $wp_query->is_tag() || $wp_query->is_tax() || $wp_query->is_search() || $wp_query->is_archive() ) ) {
     1213                wp_die( __( 'ERROR: This is not a valid feed.' ), '', array( 'response' => 404 ) );
     1214        }
     1215
    12071216        $feed = get_query_var( 'feed' );
    12081217
    12091218        // Remove the pad, if present.