<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[24481] branches/3.5: Better validation of the URL used in core HTTP requests.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/24481">24481</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2013-06-21 06:12:17 +0000 (Fri, 21 Jun 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Better validation of the URL used in core HTTP requests.

Merges <a href="http://core.trac.wordpress.org/changeset/24480">[24480]</a> to the 3.5 branch.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branches35wpadminincludesclasswpimporterphp">branches/3.5/wp-admin/includes/class-wp-importer.php</a></li>
<li><a href="#branches35wpadminincludesfilephp">branches/3.5/wp-admin/includes/file.php</a></li>
<li><a href="#branches35wpincludesclassfeedphp">branches/3.5/wp-includes/class-feed.php</a></li>
<li><a href="#branches35wpincludesclasshttpphp">branches/3.5/wp-includes/class-http.php</a></li>
<li><a href="#branches35wpincludesclassoembedphp">branches/3.5/wp-includes/class-oembed.php</a></li>
<li><a href="#branches35wpincludesclasswpxmlrpcserverphp">branches/3.5/wp-includes/class-wp-xmlrpc-server.php</a></li>
<li><a href="#branches35wpincludescommentphp">branches/3.5/wp-includes/comment.php</a></li>
<li><a href="#branches35wpincludesfunctionsphp">branches/3.5/wp-includes/functions.php</a></li>
<li><a href="#branches35wpincludeshttpphp">branches/3.5/wp-includes/http.php</a></li>
<li><a href="#branches35wpincludesrssphp">branches/3.5/wp-includes/rss.php</a></li>
</ul>

<h3>Property Changed</h3>
<ul>
<li><a href="#branches35">branches/3.5/</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<span class="cx">Index: branches/3.5
</span><span class="cx">===================================================================
</span><del>--- branches/3.5        2013-06-21 06:07:47 UTC (rev 24480)
</del><ins>+++ branches/3.5 2013-06-21 06:12:17 UTC (rev 24481)
</ins><a id="branches35"></a>
<div class="propset"><h4>Property changes: branches/3.5</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="modfile"><h4>Modified: svn:mergeinfo</h4></div>
<span class="cx"> /branches/3.1:18031
</span><span class="cx"> /branches/3.3:20543
</span><span class="cx"> /branches/3.4:21757
</span><del>-/trunk:18512,23133-23135,23139,23185,23245,23263-23264,23267,23664,23902,24436,24442,24444,24446,24448,24457,24459,24461,24463,24466,24468,24470,24472,24474,24476,24478
</del><ins>+/trunk:18512,23133-23135,23139,23185,23245,23263-23264,23267,23664,23902,24436,24442,24444,24446,24448,24457,24459,24461,24463,24466,24468,24470,24472,24474,24476,24478,24480
</ins><span class="cx">\ No newline at end of property
</span><a id="branches35wpadminincludesclasswpimporterphp"></a>
<div class="modfile"><h4>Modified: branches/3.5/wp-admin/includes/class-wp-importer.php (24480 => 24481)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.5/wp-admin/includes/class-wp-importer.php     2013-06-21 06:07:47 UTC (rev 24480)
+++ branches/3.5/wp-admin/includes/class-wp-importer.php        2013-06-21 06:12:17 UTC (rev 24481)
</span><span class="lines">@@ -183,6 +183,7 @@
</span><span class="cx"> 
</span><span class="cx">          $headers = array();
</span><span class="cx">          $args = array();
</span><ins>+               $args['reject_unsafe_urls'] = true;
</ins><span class="cx">           if ( true === $head )
</span><span class="cx">                  $args['method'] = 'HEAD';
</span><span class="cx">          if ( !empty( $username ) && !empty( $password ) )
</span></span></pre></div>
<a id="branches35wpadminincludesfilephp"></a>
<div class="modfile"><h4>Modified: branches/3.5/wp-admin/includes/file.php (24480 => 24481)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.5/wp-admin/includes/file.php  2013-06-21 06:07:47 UTC (rev 24480)
+++ branches/3.5/wp-admin/includes/file.php     2013-06-21 06:12:17 UTC (rev 24481)
</span><span class="lines">@@ -497,7 +497,7 @@
</span><span class="cx">  if ( ! $tmpfname )
</span><span class="cx">          return new WP_Error('http_no_file', __('Could not create Temporary file.'));
</span><span class="cx"> 
</span><del>-       $response = wp_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname ) );
</del><ins>+        $response = wp_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname, 'reject_unsafe_urls' => true ) );
</ins><span class="cx"> 
</span><span class="cx">  if ( is_wp_error( $response ) ) {
</span><span class="cx">          unlink( $tmpfname );
</span></span></pre></div>
<a id="branches35wpincludesclassfeedphp"></a>
<div class="modfile"><h4>Modified: branches/3.5/wp-includes/class-feed.php (24480 => 24481)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.5/wp-includes/class-feed.php  2013-06-21 06:07:47 UTC (rev 24480)
+++ branches/3.5/wp-includes/class-feed.php     2013-06-21 06:12:17 UTC (rev 24481)
</span><span class="lines">@@ -66,7 +66,11 @@
</span><span class="cx">          $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE;
</span><span class="cx"> 
</span><span class="cx">          if ( preg_match('/^http(s)?:\/\//i', $url) ) {
</span><del>-                       $args = array( 'timeout' => $this->timeout, 'redirection' => $this->redirects);
</del><ins>+                        $args = array(
+                               'timeout' => $this->timeout,
+                               'redirection' => $this->redirects,
+                               'reject_unsafe_urls' => true,
+                       );
</ins><span class="cx"> 
</span><span class="cx">                  if ( !empty($this->headers) )
</span><span class="cx">                          $args['headers'] = $this->headers;
</span><span class="lines">@@ -85,10 +89,8 @@
</span><span class="cx">                          $this->status_code = wp_remote_retrieve_response_code( $res );
</span><span class="cx">                  }
</span><span class="cx">          } else {
</span><del>-                       if ( ! file_exists($url) || ( ! $this->body = file_get_contents($url) ) ) {
-                               $this->error = 'file_get_contents could not read the file';
-                               $this->success = false;
-                       }
</del><ins>+                        $this->error = '';
+                       $this->success = false;
</ins><span class="cx">           }
</span><span class="cx">  }
</span><span class="cx"> }
</span></span></pre></div>
<a id="branches35wpincludesclasshttpphp"></a>
<div class="modfile"><h4>Modified: branches/3.5/wp-includes/class-http.php (24480 => 24481)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.5/wp-includes/class-http.php  2013-06-21 06:07:47 UTC (rev 24480)
+++ branches/3.5/wp-includes/class-http.php     2013-06-21 06:12:17 UTC (rev 24481)
</span><span class="lines">@@ -86,7 +86,8 @@
</span><span class="cx">                  'timeout' => apply_filters( 'http_request_timeout', 5),
</span><span class="cx">                  'redirection' => apply_filters( 'http_request_redirection_count', 5),
</span><span class="cx">                  'httpversion' => apply_filters( 'http_request_version', '1.0'),
</span><del>-                       'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )  ),
</del><ins>+                        'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ),
+                       'reject_unsafe_urls' => apply_filters( 'http_request_reject_unsafe_urls', false ),
</ins><span class="cx">                   'blocking' => true,
</span><span class="cx">                  'headers' => array(),
</span><span class="cx">                  'cookies' => array(),
</span><span class="lines">@@ -116,8 +117,12 @@
</span><span class="cx">          if ( false !== $pre )
</span><span class="cx">                  return $pre;
</span><span class="cx"> 
</span><del>-               $arrURL = parse_url( $url );
</del><ins>+                if ( $r['reject_unsafe_urls'] )
+                       $url = wp_http_validate_url( $url );
+               $url = wp_kses_bad_protocol( $url, array( 'http', 'https', 'ssl' ) );
</ins><span class="cx"> 
</span><ins>+               $arrURL = @parse_url( $url );
+
</ins><span class="cx">           if ( empty( $url ) || empty( $arrURL['scheme'] ) )
</span><span class="cx">                  return new WP_Error('http_request_failed', __('A valid URL was not provided.'));
</span><span class="cx"> 
</span><span class="lines">@@ -1088,6 +1093,8 @@
</span><span class="cx">          // The option doesn't work with safe mode or when open_basedir is set, and there's a
</span><span class="cx">          // bug #17490 with redirected POST requests, so handle redirections outside Curl.
</span><span class="cx">          curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, false );
</span><ins>+               if ( defined( 'CURLOPT_PROTOCOLS' ) ) // PHP 5.2.10 / cURL 7.19.4
+                       curl_setopt( $handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS );
</ins><span class="cx"> 
</span><span class="cx">          switch ( $r['method'] ) {
</span><span class="cx">                  case 'HEAD':
</span></span></pre></div>
<a id="branches35wpincludesclassoembedphp"></a>
<div class="modfile"><h4>Modified: branches/3.5/wp-includes/class-oembed.php (24480 => 24481)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.5/wp-includes/class-oembed.php        2013-06-21 06:07:47 UTC (rev 24480)
+++ branches/3.5/wp-includes/class-oembed.php   2013-06-21 06:12:17 UTC (rev 24481)
</span><span class="lines">@@ -108,7 +108,7 @@
</span><span class="cx">          $providers = array();
</span><span class="cx"> 
</span><span class="cx">          // Fetch URL content
</span><del>-               if ( $html = wp_remote_retrieve_body( wp_remote_get( $url ) ) ) {
</del><ins>+                if ( $html = wp_remote_retrieve_body( wp_remote_get( $url, array( 'reject_unsafe_urls' => true ) ) ) ) {
</ins><span class="cx"> 
</span><span class="cx">                  // <link> types that contain oEmbed provider URLs
</span><span class="cx">                  $linktypes = apply_filters( 'oembed_linktypes', array(
</span><span class="lines">@@ -190,7 +190,7 @@
</span><span class="cx">   */
</span><span class="cx">  function _fetch_with_format( $provider_url_with_args, $format ) {
</span><span class="cx">          $provider_url_with_args = add_query_arg( 'format', $format, $provider_url_with_args );
</span><del>-               $response = wp_remote_get( $provider_url_with_args );
</del><ins>+                $response = wp_remote_get( $provider_url_with_args, array( 'reject_unsafe_urls' => true ) );
</ins><span class="cx">           if ( 501 == wp_remote_retrieve_response_code( $response ) )
</span><span class="cx">                  return new WP_Error( 'not-implemented' );
</span><span class="cx">          if ( ! $body = wp_remote_retrieve_body( $response ) )
</span></span></pre></div>
<a id="branches35wpincludesclasswpxmlrpcserverphp"></a>
<div class="modfile"><h4>Modified: branches/3.5/wp-includes/class-wp-xmlrpc-server.php (24480 => 24481)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.5/wp-includes/class-wp-xmlrpc-server.php      2013-06-21 06:07:47 UTC (rev 24480)
+++ branches/3.5/wp-includes/class-wp-xmlrpc-server.php 2013-06-21 06:12:17 UTC (rev 24481)
</span><span class="lines">@@ -5380,7 +5380,8 @@
</span><span class="cx">          sleep(1);
</span><span class="cx"> 
</span><span class="cx">          // Let's check the remote site
</span><del>-               $linea = wp_remote_retrieve_body( wp_remote_get( $pagelinkedfrom, array( 'timeout' => 10, 'redirection' => 0 ) ) );
</del><ins>+                $linea = wp_remote_retrieve_body( wp_remote_get( $pagelinkedfrom, array( 'timeout' => 10, 'redirection' => 0, 'reject_unsafe_urls' => true ) ) );
+
</ins><span class="cx">           if ( !$linea )
</span><span class="cx">                  return $this->pingback_error( 16, __( 'The source URL does not exist.' ) );
</span><span class="cx"> 
</span></span></pre></div>
<a id="branches35wpincludescommentphp"></a>
<div class="modfile"><h4>Modified: branches/3.5/wp-includes/comment.php (24480 => 24481)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.5/wp-includes/comment.php     2013-06-21 06:07:47 UTC (rev 24480)
+++ branches/3.5/wp-includes/comment.php        2013-06-21 06:12:17 UTC (rev 24481)
</span><span class="lines">@@ -1661,7 +1661,7 @@
</span><span class="cx">  if ( 0 === strpos($url, $uploads_dir['baseurl']) )
</span><span class="cx">          return false;
</span><span class="cx"> 
</span><del>-       $response = wp_remote_head( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) );
</del><ins>+        $response = wp_remote_head( $url, array( 'timeout' => 2, 'httpversion' => '1.0', 'reject_unsafe_urls' => true ) );
</ins><span class="cx"> 
</span><span class="cx">  if ( is_wp_error( $response ) )
</span><span class="cx">          return false;
</span><span class="lines">@@ -1674,7 +1674,7 @@
</span><span class="cx">          return false;
</span><span class="cx"> 
</span><span class="cx">  // Now do a GET since we're going to look in the html headers (and we're sure its not a binary file)
</span><del>-       $response = wp_remote_get( $url, array( 'timeout' => 2, 'httpversion' => '1.0' ) );
</del><ins>+        $response = wp_remote_get( $url, array( 'timeout' => 2, 'httpversion' => '1.0', 'reject_unsafe_urls' => true ) );
</ins><span class="cx"> 
</span><span class="cx">  if ( is_wp_error( $response ) )
</span><span class="cx">          return false;
</span><span class="lines">@@ -1908,6 +1908,7 @@
</span><span class="cx"> 
</span><span class="cx">  $options = array();
</span><span class="cx">  $options['timeout'] = 4;
</span><ins>+       $options['reject_unsafe_urls'] = true;
</ins><span class="cx">   $options['body'] = array(
</span><span class="cx">          'title' => $title,
</span><span class="cx">          'url' => get_permalink($ID),
</span><span class="lines">@@ -1955,62 +1956,13 @@
</span><span class="cx">  * Default filter attached to pingback_ping_source_uri to validate the pingback's Source URI
</span><span class="cx">  *
</span><span class="cx">  * @since 3.5.1
</span><ins>+ * @see wp_http_validate_url()
</ins><span class="cx">  *
</span><span class="cx">  * @param string $source_uri
</span><span class="cx">  * @return string
</span><span class="cx">  */
</span><span class="cx"> function pingback_ping_source_uri( $source_uri ) {
</span><del>-       $uri = esc_url_raw( $source_uri, array( 'http', 'https' ) );
-       if ( ! $uri )
-               return '';
-
-       $parsed_url = @parse_url( $uri );
-       if ( ! $parsed_url )
-               return '';
-
-       if ( isset( $parsed_url['user'] ) || isset( $parsed_url['pass'] ) )
-               return '';
-
-       if ( false !== strpos( $parsed_url['host'], ':' ) )
-               return '';
-
-       $parsed_home = @parse_url( get_option( 'home' ) );
-
-       $same_host = strtolower( $parsed_home['host'] ) === strtolower( $parsed_url['host'] );
-
-       if ( ! $same_host ) {
-               $host = trim( $parsed_url['host'], '.' );
-               if ( preg_match( '#^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$#', $host ) ) {
-                       $ip = $host;
-               } else {
-                       $ip = gethostbyname( $host );
-                       if ( $ip === $host ) // Error condition for gethostbyname()
-                               $ip = false;
-               }
-               if ( $ip ) {
-                       if ( '127.0.0.1' === $ip )
-                               return '';
-                       $parts = array_map( 'intval', explode( '.', $ip ) );
-                       if ( 10 === $parts[0] )
-                               return '';
-                       if ( 172 === $parts[0] && 16 <= $parts[1] && 31 >= $parts[1] )
-                               return '';
-                       if ( 192 === $parts[0] && 168 === $parts[1] )
-                               return '';
-               }
-       }
-
-       if ( empty( $parsed_url['port'] ) )
-               return $uri;
-
-       $port = $parsed_url['port'];
-       if ( 80 === $port || 443 === $port || 8080 === $port )
-               return $uri;
-
-       if ( $parsed_home && $same_host && $parsed_home['port'] === $port )
-               return $uri;
-
-       return '';
</del><ins>+        return (string) wp_http_validate_url( $source_uri );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span></span></pre></div>
<a id="branches35wpincludesfunctionsphp"></a>
<div class="modfile"><h4>Modified: branches/3.5/wp-includes/functions.php (24480 => 24481)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.5/wp-includes/functions.php   2013-06-21 06:07:47 UTC (rev 24480)
+++ branches/3.5/wp-includes/functions.php      2013-06-21 06:12:17 UTC (rev 24481)
</span><span class="lines">@@ -496,6 +496,7 @@
</span><span class="cx"> 
</span><span class="cx">  $options = array();
</span><span class="cx">  $options['redirection'] = 5;
</span><ins>+       $options['reject_unsafe_urls'] = true;
</ins><span class="cx"> 
</span><span class="cx">  if ( false == $file_path )
</span><span class="cx">          $options['method'] = 'HEAD';
</span><span class="lines">@@ -543,7 +544,7 @@
</span><span class="cx">  if ( !empty( $deprecated ) )
</span><span class="cx">          _deprecated_argument( __FUNCTION__, '2.7' );
</span><span class="cx"> 
</span><del>-       $response = wp_remote_head( $url );
</del><ins>+        $response = wp_remote_head( $url, array( 'reject_unsafe_urls' => true ) );
</ins><span class="cx"> 
</span><span class="cx">  if ( is_wp_error( $response ) )
</span><span class="cx">          return false;
</span><span class="lines">@@ -758,6 +759,7 @@
</span><span class="cx"> 
</span><span class="cx">  $options = array();
</span><span class="cx">  $options['timeout'] = 10;
</span><ins>+       $options['reject_unsafe_urls'] = true;
</ins><span class="cx"> 
</span><span class="cx">  $response = wp_remote_get( $uri, $options );
</span><span class="cx"> 
</span></span></pre></div>
<a id="branches35wpincludeshttpphp"></a>
<div class="modfile"><h4>Modified: branches/3.5/wp-includes/http.php (24480 => 24481)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.5/wp-includes/http.php        2013-06-21 06:07:47 UTC (rev 24480)
+++ branches/3.5/wp-includes/http.php   2013-06-21 06:12:17 UTC (rev 24481)
</span><span class="lines">@@ -311,3 +311,64 @@
</span><span class="cx"> 
</span><span class="cx">  return false;
</span><span class="cx"> }
</span><ins>+
+/**
+ * Validate a URL for safe use in the HTTP API.
+ *
+ * @since 3.5.2
+ *
+ * @return mixed URL or false on failure.
+ */
+function wp_http_validate_url( $url ) {
+       $url = esc_url_raw( $url, array( 'http', 'https' ) );
+       if ( ! $url )
+               return false;
+
+       $parsed_url = @parse_url( $url );
+       if ( ! $parsed_url )
+               return false;
+
+       if ( isset( $parsed_url['user'] ) || isset( $parsed_url['pass'] ) )
+               return false;
+
+       if ( false !== strpos( $parsed_url['host'], ':' ) )
+               return false;
+
+       $parsed_home = @parse_url( get_option( 'home' ) );
+
+       $same_host = strtolower( $parsed_home['host'] ) === strtolower( $parsed_url['host'] );
+
+       if ( ! $same_host ) {
+               $host = trim( $parsed_url['host'], '.' );
+               if ( preg_match( '#^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$#', $host ) ) {
+                       $ip = $host;
+               } else {
+                       $ip = gethostbyname( $host );
+                       if ( $ip === $host ) // Error condition for gethostbyname()
+                               $ip = false;
+               }
+               if ( $ip ) {
+                       if ( '127.0.0.1' === $ip )
+                               return false;
+                       $parts = array_map( 'intval', explode( '.', $ip ) );
+                       if ( 10 === $parts[0] )
+                               return false;
+                       if ( 172 === $parts[0] && 16 <= $parts[1] && 31 >= $parts[1] )
+                               return false;
+                       if ( 192 === $parts[0] && 168 === $parts[1] )
+                               return false;
+               }
+       }
+
+       if ( empty( $parsed_url['port'] ) )
+               return $url;
+
+       $port = $parsed_url['port'];
+       if ( 80 === $port || 443 === $port || 8080 === $port )
+               return $url;
+
+       if ( $parsed_home && $same_host && $parsed_home['port'] === $port )
+               return $url;
+
+       return false;
+}
</ins></span></pre></div>
<a id="branches35wpincludesrssphp"></a>
<div class="modfile"><h4>Modified: branches/3.5/wp-includes/rss.php (24480 => 24481)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.5/wp-includes/rss.php 2013-06-21 06:07:47 UTC (rev 24480)
+++ branches/3.5/wp-includes/rss.php    2013-06-21 06:12:17 UTC (rev 24481)
</span><span class="lines">@@ -536,7 +536,7 @@
</span><span class="cx">  * @return Snoopy style response
</span><span class="cx">  */
</span><span class="cx"> function _fetch_remote_file($url, $headers = "" ) {
</span><del>-       $resp = wp_remote_request($url, array('headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT));
</del><ins>+        $resp = wp_remote_request($url, array('headers' => $headers, 'timeout' => MAGPIE_FETCH_TIME_OUT, 'reject_unsafe_urls' => true ));
</ins><span class="cx">   if ( is_wp_error($resp) ) {
</span><span class="cx">          $error = array_shift($resp->errors);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>