RSS WordPress SimplePie claiming valid URL as invalid RSS WordPress SimplePie claiming valid URL as invalid wordpress wordpress

RSS WordPress SimplePie claiming valid URL as invalid


Since this is the first hit in google, probably worth me adding this possible solution:

For our instance - an intranet site, pulling an rss feed from another internal page, which in-turn resolves to an RFC1918 private address the feed was being blocked by Wordpress's URL checker for security reasons.

The easiest fix in my instance was to add the following to functions.php, but this does have security implications so be sure you understand it before you add it:

add_filter( 'http_request_args', function( $args ) {   $args['reject_unsafe_urls'] = false;   return $args;} );

Further discussion and more information at - https://core.trac.wordpress.org/ticket/24646


By adding preg_match for specific urls we can minimize the amount of parsed unsafed urls:

function http_request_local( $args, $url ) {   if ( preg_match('/xml|rss|feed/', $url) ){      $args['reject_unsafe_urls'] = false;         }   return $args;}add_filter( 'http_request_args', 'http_request_local', 5, 2 );


So, while the above answers work, I think that there's a way to do this that is better to make sure that you're limiting the scope of where you're making the URL request to instead of allowing everything to go. So I'm proving the following information to anyone who stumbles across this just in case it helps.

This answer is useful if the resulting calls are to internal servers cross-communicating on private IPs but are still publicly accessible.

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.

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);