[wp-trac] [WordPress Trac] #24646: fetch_feed() returns WP_Error with "A valid URL was not provided"

WordPress Trac noreply at wordpress.org
Fri Oct 4 19:50:23 UTC 2019


#24646: fetch_feed() returns WP_Error with "A valid URL was not provided"
--------------------------+---------------------
 Reporter:  husdaman      |       Owner:  nacin
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:  3.6
Component:  Feeds         |     Version:  3.5.2
 Severity:  major         |  Resolution:  fixed
 Keywords:  fixed-major   |     Focuses:
--------------------------+---------------------

Comment (by jaysauce):

 I know that this thread is very old and also closed, but I came across
 this and found some solutions that may help others in the future as
 following some of the posts above helped me in finding the answer I'm
 about to provide.

 This answer is useful if the resulting calls are to internal servers
 cross-communicating on private IPs but are still publicly accessible. I
 don't know exactly if this is a more secure way of doing it or not, but it
 sure seems to be as you're limiting the scope of what's allowed.

 The snippet below is to be run on the site that's calling the RSS feed.
 The site that is providing the feed does not need this.

 {{{#!php
 <?php
 add_filter('http_request_host_is_external', function($bool, $host, $url){
         if($url === 'https://www.example.com/news/feed/' && $host ===
 'www.example.com'){
                 return true;
         }
 }, 10, 3);
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/24646#comment:52>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list